我有这三种模式:的EntityFramework 4.3 codefirst使用TPT和鉴别
public class Equipment
{
public int ID { get; set; }
public string title { get; set; }
}
[Table("Vessels")]
public class Vessel:Equipment
{
public string Size { get; set; }
}
[Table("Tubes")]
public class Tube : Equipment
{
public string Pressure{ get; set; }
}
我要显示设备的2列标题和类型的列表。
例如:
Title Type
------ -------
101-1 vessel
101-2 vessel
102-3 tube
我不知道如何在设备鉴别栏,显示各设备的类型。
EDITED
如果我有这样的设备实体鉴别:
public class Equipment
{
public int ID { get; set; }
public string title { get; set; }
public string type{ get; set; } //as discriminator
}
我可以得到查询的控制器或存储库这样的:
var equipments=from e in db.Equipments
select e;
最后一个查询如何依赖于鉴别器? –
非常感谢,我想我知道我的错误在哪里。我想像TPH一样自动填充Type(鉴别器),但是现在明白我必须在每个我将从容器和管中获得的实例中设置代码值。非常感谢@LadislavMrnka –