Reputation: 1521
This page shows nicely how to cope with different scenario's for fetching data: http://msdn.microsoft.com/en-us/library/gg671236%28v=vs.103%29.aspx
How do I select a collection and two references? (Lines have a ProductId and an AddressId, I want to include both...)
In other words, where do I put my Level1Reference2
in:
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))
To include a collection, a collection, and a reference two levels down: query.Include(e => e.Level1Collection.Select(l1 => l1.Level2Collection.Select(l2 => l2.Level3Reference)))
Upvotes: 0
Views: 196
Reputation: 109079
Just repeat an Include:
query.Include(e => e.Lines.Select(l1 => l1.Level1Reference))
.Include(e => e.Lines.Select(l1 => l1.Level1Reference2))
Upvotes: 1