If I have an Employee entity, with derived entity types thus:
class Employee
{ // ...
}
class FireWarden : Employee
{ // ...
}
class KeyHolder : Employee
{ // ...
}
how can I query Employees that are neither fire wardens or key holders, nor any other special type of employee?
Some things I've tried:
Employees.OfType<Employee>(). ...
returns all employees (as you'd expect).
Employees.Where(e => (e.GetType() == TypeOf(Employee)). ...
fails with a runtime error saying something along the lines of Entity Framework doesn't support GetType().
I could write
var normalEmployees = Employees.Where(e => !(e is FireWarden || e is KeyHolder));
but then if I introduce a new entity derived from Employee, I would need to be sure to update all such queries to exclude the new type.
I suppose I could add a "SpecialEmployee" class, deriving from Employee, and derive other types form that. Then I wouldn't have to update all queries, but this feels a bit like the tail is wagging the dog.