Entity Framework: получение объектов подкласса в репозитории

У меня есть следующая модель, соответствующая таблицам базы данных, перечисленным ниже.

Менеджер - это работник. Бухгалтер также является работником.

What is the best method to get all managers in the repository? How to implement GetAllManagers() method? Is it proper TPT?

enter image description here

КОД

MyRepository.MyEmployeeRepository rep = new MyEmployeeRepository();
List<Employee> e = rep.GetAllEmployees();



public class MyEmployeeRepository
{
    private string connectionStringVal;
    public MyEmployeeRepository()
    {
        SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
        sqlBuilder.DataSource = ".";
        sqlBuilder.InitialCatalog = "LibraryReservationSystem";
        sqlBuilder.IntegratedSecurity = true;

        // Initialize the EntityConnectionStringBuilder.
        EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
        entityBuilder.Provider = "System.Data.SqlClient";
        entityBuilder.ProviderConnectionString = sqlBuilder.ToString();
        entityBuilder.Metadata = @"res://*/Test.csdl|res://*/Test.ssdl|res://*/Test.msl";

        connectionStringVal = entityBuilder.ToString();


    }


    public List<Employee> GetAllEmployees()
    {

        List<Employee> employees = new List<Employee>();
        using (var context = new MyEntityDataModelEDM.LibraryReservationSystemEntities1(connectionStringVal))
        {
            foreach (MyEntityDataModelEDM.Employee p in context.Employees)
            {
                employees.Add(p);
            }
        }

        return employees;
    }

    public List<Manager> GetAllManagers()
    {

        List<Manager> managers = new List<Manager>();
        using (var context = new MyEntityDataModelEDM.LibraryReservationSystemEntities1(connectionStringVal))
        {


        }

        return managers;
    }



}

EDIT

У этой модели есть недостатки. Следует учитывать следующее:

Employee can be created without any role for him. One employee can have multiple roles.

Ответы на вопрос(1)

Ваш ответ на вопрос