Using EF Core 1.1.0
I have a model that has collections that themselves have collections.
public class A {
public string Ay {get;set;}
public List<B> Bees {get;set;}
}
public class B {
public string Be {get;set;}
public List<C> Seas {get;set;}
}
public class C {
public string See {get;set;}
public bool InDark {get;set;}
public List<D> Sigh {get;set;}
}
Now.. A is huge, and 99% of the time I don't care about B, so it doesn't get loaded. If I did load it, then it would be something like:
context.A.Include(a=>a.Bees).ThenInclude(b=>b.Seas).ThenInclude(c=>c.Sigh)...
Now let's say I already have A loaded up and the 1% happens for me to care about B. We don't have lazy loading yet, but the last release did give us explicit loading. Awesome.
context.Entry(A).Collection(a=>a.Bees).Load();
Problem seems to be that there isn't a way to include the additional collections inside B? Do I have no choice but to reload A with the .Include.ThenInclude.ThenInclude.Etc?
Fortunately you have an option. Instead of directly calling
Load
, you can useQuery
method and apply as manyInclude
/ThenInclude
as you wish.For your sample, it would be something like this: