在Ado.net实体框架中继承

时间:2011-04-04 00:15:33

标签: entity-framework

enter image description here

我有实体NhanVienQuanLy继承自实体NhanVien。

 var context = new Model1Container();
 var result = context.NhanViens;
 var resultNV = context.NhanVienQuanLys // not exist

如何获取实体集NhanVienQuanLy的数据?

1 个答案:

答案 0 :(得分:2)

你应该可以这样做:

var resultNV = context.NhanViens.OfType<NhanVienQuanLy>();

或在查询语法中查询时:

from n in context.NhanViens where n is NhanVienQuanLy select n;