Assume we have this model :
public class Tiers
{
public List Contacts { get; set; }
}
and
public class C
For completeness' sake:
It is also possible to include nested properties directly via Include in case they are not collection properties like so:
_dbSet
.Include(tier => tier.Contact.Titre)
.Include(tier => tier.Contact.TypeContact)
.Include(tier => tier.Contact.Langue);
.ThenInclude() will chain off of either the last .ThenInclude() or the last .Include() (whichever is more recent) to pull in multiple levels. To include multiple siblings at the same level, just use another .Include() chain. Formatting the code right can drastically improve readability.
_dbSet
.Include(tiers => tiers.Contacts).ThenInclude(contact => contact.Titre)
.Include(tiers => tiers.Contacts).ThenInclude(contact => contact.TypeContact)
.Include(tiers => tiers.Contacts).ThenInclude(contact => contact.Langue);
// etc.