4

I can't seem to find how to eager load multiple child child collections in EF. So I can do:

blawConext.Blaws
    .Include(b => b.ChildCollection
             .Select(cc => cc.ChildChildCollection)
     )

I can even go deeper and deeper without a problem but I can't get the umm peer? collection, The below does not work

blawConext.Blaws
    .Include(b => b.ChildCollection
             .Select(cc => cc.ChildChildCollection1)
             .Select(cc => cc.ChildChildCollection2)
     )
rethenhouser2
  • 400
  • 1
  • 3
  • 14
  • The only way I've found that seems to work is to use two Includes with duplicate paths except for the end. So one full include branching all the way down to ChildChildCollection1, and then a second include exactly the same but with ChildChildCollection2, but that seems wrong – rethenhouser2 Feb 07 '13 at 20:39

1 Answers1

4

You can specify multiple includes:

blawConext.Blaws
    .Include(b => b.ChildCollection.Select(cc => cc.ChildChildCollection1))
    .Include(b => b.ChildCollection.Select(cc => cc.ChildChildCollection2))
jrummell
  • 42,637
  • 17
  • 112
  • 171