An object in my database has 2 navigational properties (B and C):
Object A
{
B bProperty
C cProperty
}
I wish to include them both when querying object A. I tried doing the following:
dbcontext.A.Include(x => x.B).ToList();
But how do I include C too?
Try this
dbcontext.A.Include(x => x.B).Include(x => x.C).ToList();
I do it all in one go, so in my EF repository class, I have a method called GetAllIncluding which equals do it in a generic way for each entity,
where DbSet is a private member of type IDbSet and T is a of type BaseEntity.
and the way I use it is like this
Hope that helps.