我确实有一个复杂的查询来选择一个名为Performance
的完整对象与其他对象的效果关系是:
与Spot和Measurement的项目关系:
下面的查询完全返回我想要的内容,但我想将Spot和Measurement包含在Item对象中。
return _context.Performance.Include(i => i.Indexes
.Select(s => s.SubIndexes
.Select(d => d.Indicators
.Select(t => t.Items))))
.SingleOrDefault(p => p.Id == id);
我已经尝试了下面的查询,它正在返回Measurement对象。如何包含Spot对象?
return _context.Performance.Include(i => i.Indexes
.Select(s => s.SubIndexes
.Select(d => d.Indicators
.Select(t => t.Items.Select(tm => tm.Measurement)))))
.SingleOrDefault(p => p.Id == id);
答案 0 :(得分:1)
您也可以添加第二个Include
;
return _context.Performance.Include(i => i.Indexes
.Select(s => s.SubIndexes
.Select(d => d.Indicators
.Select(t => t.Items.Select(tm => tm.Measurement)))))
.Include(i => i.Indexes
.Select(s => s.SubIndexes
.Select(d => d.Indicators
.Select(t => t.Items.Select(tm => tm.Spot)))))
.SingleOrDefault(p => p.Id == id);