Eager loading property of derived class using Include

前端 未结 4 1542
我在风中等你
我在风中等你 2020-12-09 10:41

I have classes like:

Person
{
   Name
   Address
}

Employee : Person
{
   Compensation - object
}

Visitor : Person
{

}

If I write linq:<

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 11:27

    var employees = context.Persons.OfType().Include(x => x.Compensation).ToArray();
    
    var nonEmployees = context.Persons.Except(context.Persons.OfType()).ToArray();
    
    var people = employees.Concat(nonEmployees);
    

提交回复
热议问题