将EF 6中的存储过程映射到抽象类型

时间:2015-06-04 17:25:39

标签: c# entity-framework ef-code-first

我的数据模型使用继承(我正在尝试更改...),但看起来像:

abstract class Entity 
{
    public int foo { get; set; }
}

class Derived1 : Entity
{
    public int WidgetCount { get; Set; }
}

class Derived2 : Entity
{
    public int BarCount { get; set; }
}

我想检索返回实体的查询(或存储过程)的结果,但.ExecuteStoreCommand<T> .Translate<T>.SqlQuery<T>都失败了,因为它们无法创建实体但是针对DbContext的DbSet<Entity>的查询有效,并返回正确类型的对象(Derived1或Derived2)。

我有没有办法在不使用DbSet的情况下查询实体?

0 个答案:

没有答案
相关问题