I have various types of EF entities, all of them have a navigation property called "Employee". When generating reports the user will have the option to filter the report according to the different employee propertoes (Cost Center, gender, etc.).
Currently I am filtering each query individually, for example:
var courses = context.Courses
.Where(c => c.Employee.CostCenterID == ccID
&& c.Employee.Rank == rankID
....
)
.ToList();
The real filter code is much more longer but this was just a hint. Anyway, is there a way to create a generic method to filter the result by the employee? all the entities I will supply to this filter method will have an Employee
navigation property. I will simply supply a IQueryable<entity>
or ObjectSet<entity>
and then get a filtered IQueryable<entity>
or ObjectSet<entity>
.
How to do that?