Supposing my Application consumes two tables represented as two entities: Person and Employee.
And:
- I am not allowed to make changes in table person. (I suggest get data from a view)
- Employee must inherit from Person.
I am trying to implement Table-Per-Type inheritance, but I don't know how to insert rows in table Employee.
EmployeesRepository:
public MenuItem GetByPersonId(int personId)
{
return (from e in _entities.People.OfType<Employee>()
where e.PersonId== personId
select e).FirstOrDefault();
}
public void Add(Employee employee)
{
_entities.AddToPeople(employee); //Here it doesn't work
}
public void Save()
{
_entities.SaveChanges();
}