var result = ParentTable.Set
.Include("Children")
.Include("Children.GrandChildren")
.SelectMany(p=>p.Children)
.Where(c=>c.GrandChildren.Any(whatever))
will return null, even though
var result = ParentTable.Set
.Include("Children")
.Include("Children.GrandChildren")
has the fully populated data in it.
Its needed to do
var result = ParentTable.Set
.SelectMany(p=>p.Children)
.Include("GrandChildren")
.Where(c=>c.GrandChildren.Any(whatever))
This example is a bit contrived, but I ran into this problem as part of a larger more complicated query where a subselect projection was using SelectMany to populate a count into a particular property, and other data was being projected into other properties from outside the selectMany, and those properties were populating, but the selectmany count was not. It was very confusing how different parts of the query had different parts of the same data lazy loaded!