Reputation: 2663
I have an Entity Framework Model similar to this:
I can Add,Query (Using OfType), and Update Employees and Contacts with no problem. However, I can not determine what type a Person object is. Say for example:
var person = entities.People.Single(p => p.Id == 5);
How can I do this:
if (person.IsEmployee){
//do something
} else if (person.IsContact) {
// do something else
}
Alternatively, I can settle for this:
if (person.IsOfType<Employee>()){
// do something
} else if (person.IsOfType<Contact>()) {
// do something else
}
Is there a way?
Upvotes: 1
Views: 1412
Reputation: 126547
if (person is Employee){
//do something
} else if (person is Contact) {
// do something else
}
Upvotes: 12