此页面很好地展示了如何处理获取数据的不同方案:http://msdn.microsoft.com/en-us/library/gg671236%28v=vs.103%29.aspx
如何选择集合和两个引用?(行有一个ProductId和一个AddressId,我想要同时包含它们.. 。)
换句话说,我将Level1Reference2
放在哪里:
query.Include(e => e.Lines.Select(l1 => l1.Level1Reference))
// Level1Reference2?
query.Include(e => e.Level1Reference)
query.Include(e => e.Level1Collection)
query.Include(e => e.Level1Reference.Level2Reference)
query.Include(e => e.Level1Reference.Level2Collection)
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Reference))
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Collection))
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Reference))
query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Reference.Level3Reference))
要包含集合,集合,引用两个级别:query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Collection.Select(l2 => l2.Level3Reference)))
答案 0 :(得分:1)
重复一个包含:
query.Include(e => e.Lines.Select(l1 => l1.Level1Reference))
.Include(e => e.Lines.Select(l1 => l1.Level1Reference2))