Is it possible to include an additional navigation property in a nested hierarchical type in the Entity Framework?

Even my question heading is a little sip, but what I'm trying to do is to avoid extra round trips to the database. What I want to achieve is using Entity Framework 6 (or later, if any).

If I have an object that has the property of a set of hierarchical objects, but in one case one of the types of inherited object types, I want to expand the additional navigation property (this is also a collection), is this possible?

To extend the navigation property, you use the "Include" keyword with the specified property, but how does this work with a base class type with inherited objects?

eg. Pseudo code thinking

Context.ParentType .Include(pt => pt.SubCollection) .Include(pt => pt.SubCollection.OfType<SpecialSubType>().SpecialProperty) 

or something?

Thus, the result of this will be that my parent type will have an auxiliary collection fully materialized in the request, but, as part of this, the specialized subsection (having several other types) also includes SpecialtyProperty navigation for this specified subtype.

+5
source share

All Articles