Entity Framework: Get Subclass objects in Repository

前端 未结 1 1676
粉色の甜心
粉色の甜心 2021-01-17 06:03

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 be
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 06:47

    Just do:

    return context.Employees.OfType().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 讨论(0)
提交回复
热议问题