假设以下层次:实体框架:继承与包括
class Department { EntityCollection<Employee> Employees; }
class Employee { string Name; }
class RemoteEmployee : Employee { Country Location; EntityReference<Country> CountryReference; }
所以,部门包含员工的列表。有员工类型的层次结构,某些类型引用其他实体。 假设我们需要将员工加载到部门。好的,不是问题:
dataContext.Departments.Include("Employees")
这将返回具体的员工类型(即远程员工的RemoteEmployee)。 现在我们需要使用远程员工加载位置。
dataContext.Departments.Include("Employees").Include("Employees.Location") - Error: no such property in Employee
dataContext.Departments.Include("Employees").Include("RemoteEmployees.Location") - Error: no such property in Department
我应该在Include中指定要使用RemoteEmployee加载位置的内容吗?
ALex的解决方案出了什么问题。你为什么不接受它,以便从中得到回报? – VdesmedT 2011-06-04 05:14:47