Entity framework 4 实体框架继承-确定对象类型
我有一个与此类似的实体框架模型:Entity framework 4 实体框架继承-确定对象类型,entity-framework-4,Entity Framework 4,我有一个与此类似的实体框架模型: 人 员工(继承人) 联系人(继承人) 我可以毫无问题地添加、查询(使用OfType)和更新员工和联系人。但是,我无法确定Person对象的类型。比如说: var person = entities.People.Single(p => p.Id == 5); 我如何做到这一点: if (person.IsEmployee){ //do something } else if (person.IsContact) { // do something el
var person = entities.People.Single(p => p.Id == 5);
我如何做到这一点:
if (person.IsEmployee){
//do something
} else if (person.IsContact) {
// do something else
}
或者,我可以满足于此:
if (person.IsOfType<Employee>()){
// do something
} else if (person.IsOfType<Contact>()) {
// do something else
}
if(person.IsOfType()){
//做点什么
}else if(person.IsOfType()){
//做点别的
}
有办法吗
if (person is Employee){
//do something
} else if (person is Contact) {
// do something else
}