Entity Framework - Inheritance Request

I was tasked with doing my homework to do a task tracker. I wanted to study the entity structure for this assignment, especially how to use aspects of inheritance. Projects, tasks, and subtasks have many similar properties, so I thought I would use inheritance, but I can’t figure out how to request specific projects.

I drew this diagram in Visual Studio:

Entity Diagram

Then I created a database from this model. How can I get employee projects?

I started with this:

ModelContainer m = new ModelContainer();
var employee = (from e in m.Employees 
               where e.UserName == username
               select e).First<Employee>();

But ((Employee)employee).Projectsunavailable, but ((Employee)employee).Itemsthere is. ((Employee)employee).Items.Projectsalso unavailable. How to get Employee projects? Should I add a navigation property for employees for this?

+3
1

Queryable.OfType(TResult) Manager:

using (var model = new ModelContainer())
{
    Manager manager = (from m in model.Employees.OfType<Manager>()
                       where m.UserName == username
                       select m).FirstOrDefault();
}

:

+3

Source: https://habr.com/ru/post/1777799/


All Articles