Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:58:03+00:00 2026-06-08T11:58:03+00:00

I have following model corresponding to the database tables listed below. A manager is

  • 0

I have following model corresponding to the database tables listed below.

A manager is an employee. An accountant also is an employee.

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

enter image description here

CODE

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

This model has drawbacks. It should consider following:

  1. Employee can be created without any role for him.
  2. One employee can have multiple roles.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:58:04+00:00Added an answer on June 8, 2026 at 11:58 am

    Just do:

    return context.Employees.OfType<Accountant>().ToList()
    

    This is however a really bad way to model employees.. if an accountant changes job, you need to kill and recreate that object..

    See my answer on Inheritance vs enum properties in the domain model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model: public class Tag { public int Id { get;
I have models corresponding to database tables. For example, the House class has color,
I have the following database relational schema that purports to model an EMP supertype
In Codeigniter, I have the following model function get_item_history($id) { //from metadata_history get item_id
I have the following model: public class Contact { public Contact() { Name =
I have the following model: WebPromocion: connection: doctrine tableName: WebPromocion columns: id: type: integer(4)
I have the following Model pattern: public abstract class PARENTCLASS {...} public class CHILD_A_CLASS
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo
I have the following model: class User: name = models.CharField( max_length = 200 )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.