I have classes like:
Person
{
Name
Address
}
Employee : Person
{
Compensation - object
}
Visitor : Person
{
}
If I write linq:<
Here's a nice example of how to load Persons and include Compensation for Employees
Replace Reference() by Collection() for a collection property.
IQueryable GetPersons()
{
var persons = Context.Persons;
foreach(var entry in persons.OfType())
Context.Entry(entry).Reference(e => e.Compensation).Load();
return persons;
}
Not sure either if it's efficient, but it works, and the intention is clearer than with joins.
Based on this SO answer