.net - Entity Framework - Querying Inheritance -
i tasked homework assignment make task tracker. wanted learn entity framework assignment, how use inheritance aspects. projects, tasks , sub-tasks have lot of similar properties, thought use inheritance, can't figure out how query particular projects.
i drew diagram in visual studio:
i created database model. how can employees projects?
i've started this:
modelcontainer m = new modelcontainer(); var employee = (from e in m.employees e.username == username select e).first<employee>();
but ((employee)employee).projects
not available, ((employee)employee).items
is. ((employee)employee).items.projects
not available. how employee's projects? should add navigation property employees this?
you'll have use queryable.oftype(tresult) extension method in order filter entities of type manager:
using (var model = new modelcontainer()) { manager manager = (from m in model.employees.oftype<manager>() m.username == username select m).firstordefault(); }
related resources:
Comments
Post a Comment