实体框架继承 - 确定对象类型

Alf*_*ono 1 entity-framework-4

我有一个与此类似的实体框架模型:

  1. 员工(继承人)
  2. 联系(继承人)

我可以添加,查询(使用OfType)和更新员工和联系人没有问题.但是,我无法确定Person对象的类型.比如说:

var person = entities.People.Single(p => p.Id == 5); 
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点:

if (person.IsEmployee){
//do something
} else if (person.IsContact) {
// do something else
}
Run Code Online (Sandbox Code Playgroud)

或者,我可以满足于此:

if (person.IsOfType<Employee>()){
// do something
} else if (person.IsOfType<Contact>()) {
// do something else
}
Run Code Online (Sandbox Code Playgroud)

有办法吗?

Cra*_*ntz 12

if (person is Employee){
//do something
} else if (person is Contact) {
// do something else
}
Run Code Online (Sandbox Code Playgroud)