Entity framework 实体框架中派生类的快速加载
我有一个这样的模型:Entity framework 实体框架中派生类的快速加载,entity-framework,inheritance,eager-loading,Entity Framework,Inheritance,Eager Loading,我有一个这样的模型: public abstract class Point { public int Id { set; get; } public string Name_F { set; get; } public byte Side { set; get; } } public class Place : Point { public bool IsATM { set; get; } public bool Is24h { set; get; }
public abstract class Point
{
public int Id { set; get; }
public string Name_F { set; get; }
public byte Side { set; get; }
}
public class Place : Point
{
public bool IsATM { set; get; }
public bool Is24h { set; get; }
public string Tel { set; get; }
public virtual Category Category { set; get; }
}
public class Street : Point
{
public bool IsWalkway { set; get; }
}
我想加载所有点表记录,包括从Point类派生的Place和Street记录
我使用了这个,但没有得到任何数据:
var points = Context.Points
.OfType<Place>()
.Include(p => p.SubCategory)
.Concat<Points>(Context.Points.OfType<Street>());
var points=Context.points
第()类
.包括(p=>p.子类别)
.Concat(Context.Points.OfType());
我想在同一个查询中得到地点和街道
有什么想法吗?这甚至不能运行
Points.OfType()
隐式转换为IQueryable
,因此无法识别导航属性子类别。您必须在两个separate查询中获取数据。@GertArnold它运行。我已经检查过了,但当我添加Concat术语时,它什么也检索不到。这甚至不能运行Points.OfType()
隐式转换为IQueryable
,因此无法识别导航属性子类别。您必须在两个separate查询中获取数据。@GertArnold它运行。我已经检查过了,但是当我添加Concat术语时,它什么也检索不到。