问题
How do I use ValueInjecter with a LINQ join that joins multiple result sets? For example, this code inject result
values into CombinedResult
object, but I also want some of errorsAndWarning
values into CombinedResult
. The properties have the same name:
var combined = from result in results.DeferredItems
join errorsAndWarning in errorsAndWarnings.DeferredItems
on result.MeetingID equals errorsAndWarning.MeetingID
select new CombinedResult().InjectFrom(result) as CombinedResult;
Thanks.
回答1:
Use this:
var combined = from result in results.DeferredItems
join errorsAndWarning in errorsAndWarnings.DeferredItems
on result.MeetingID equals errorsAndWarning.MeetingID
select new CombinedResult().InjectFrom(result)
.InjectFrom(errorsAndWarning)
as CombinedResult;
来源:https://stackoverflow.com/questions/10143241/valueinjecter-joins-multiple-result-sets-into-1-collection-linq