We have the following model in EFCore set up using Table Per Hierarchy (simplified for clarity):
public class User {
public int Id { get; set; }
}
public class Student : User {
public Company Company { get; set; }
}
public class Teacher : User {
public Company School { get; set; }
}
I want to get all users (both Students and Teachers) with all references included. Basically I want to do the following in one query:
_context.Users.OfType<Teacher>().Include(x => x.School);
_context.Users.OfType<Student>().Include(x => x.Company);
Is there a way to do that?