I have some classes:
public Department {
public HashSet<Employee> Managers {get; set;}
public HashSet<Employee> Workers {get; set;}
public HashSet<Asset> Assets {get; set;}
}
I am using IQueryable to get a deparment collection:
IQueryable<Department> deparments = Context.Department.Where (
dept => dept.CompanyId = id)
.include (dept.Managers.Where (emp => emp.level == Position.Manager) as Managers)
.include (dept.Workers.Where (emp => emp.level == Position.Worker) as Workers)
.include (dept.Asset)
It gave errors when the query is executed. What is the right way to do this? Here is the error msg:
"The Include property lambda expression 'dept => {from Employee emp in dept.Employee where ([emp].Position == Position.Manager) select [emp]}' is invalid. The expression should represent a property access: 't => t.MyProperty'. To target navigations declared on derived types, specify an explicitly typed lambda parameter of the target type, E.g. '(Derived d) => d.MyProperty'.
For more information on including related data, see http://go.microsoft.com/fwlink/?LinkID=746393."