ValueInjecter - 将多个结果集连接到1个集合LINQ中?

时间:2012-04-13 14:58:48

标签: c# .net linq valueinjecter

如何将ValueInjecter与连接多个结果集的LINQ连接一起使用?例如,此代码会将result值注入CombinedResult个对象,但我还希望将errorsAndWarning个值转换为CombinedResult。这些属性具有相同的名称:

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;

感谢。

1 个答案:

答案 0 :(得分:3)

使用此:

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;