[英]C# LINQ Include
I have a problem with Include()
in Entity Framework. 我在Entity Framework中的
Include()
有问题。
I have some entities 我有一些实体
public partial class Travel_RequestEmployee
{
public virtual Traveler Traveler { get; set; }
}
public abstract partial class Traveler{
}
public partial class Traveler_Employee : Traveler
{
public virtual Employee Employee { get; set; }
}
I want to Include Employee Properties from Travel_RequestEmployee
. 我想包括
Travel_RequestEmployee
Employee属性。 Is there a way to get Include()
working like this? 有没有办法让
Include()
像这样工作?
_context.Travel_RequestEmployee.Include(x =>
x.Traveler.OfType<Traveler_Employee>().Include(e => e.Employee));
Please help me? 请帮我?
You are using the wrong type. 您使用了错误的类型。
public partial class Travel_RequestEmployee
{
public virtual Traveler_Employee Traveler { get; set; }
}
notice the switch to Traveler_Employee. 注意切换到Traveler_Employee。 Traveler is a base class.
旅行者是基础阶级。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.