ValueInjecter - Joins multiple result sets into 1 collection LINQ?

此生再无相见时 提交于 2019-12-11 09:16:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!