I have a class Employee
that looks like the following:
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public int Manager { get; set; }
}
I have another class Manager
that extends this class and adds no other functionality:
public class Manager : Employee
{
}
In my DbContext
derived class I have:
public DbSet<Employee> Employees { get; set; }
public DbSet<Manager> Managers { get; set; }
I want employee's with Employee.Manager == 1
to be added to the Managers
DbSet
and the employee's with Employee.Manager == 0
to be added to the Employees
DbSet
.
The database table is structured in this way and I need to be able to do something like this, because I have another class which has a foreign key to an employee and one to a manager.
How can I accomplish this or is there another way to solve my problem?
Manager
value is your Discriminator? - Claies