Suppose I have 3 table: Table Employee, EmploymentHistory, and Languages. One employee can have many language and employment history.
Employee
ID Name Email
1 AAA [email protected]
2 BBB [email protected]
3 CCC [email protected]
Employment History
ID EmployeeID Company Position
1 1 Devon Energy aaa
2 2 Emric bbb
3 3 Capcom ccc
Language
ID EmployeeID Language Level
1 1 English Expert
2 2 Dutch Expert
3 3 Franch Expert
How to apply filter using ObjectQuery QueryBuilder ? Example: I want to filter employee with devon company. It should be employee "AAA".
var emp = Translate(context.Employees.Include("EmploymentHistories"));
public ObjectQuery<T> Translate<T>(ObjectQuery<T> objectQuery)
{
objectQuery.Where("it.EmploymentHistories.Company = 'Devon Energy'"); // EmploymentHistories.Company is not found. How can I filter through it included property
}
Note: I'm using QueryBuilder for advanced filtering.
Best regards,
Brian
After 1 Day of excruciating pain, Finally I've found the solution. I used dynamic linq provided by microsoft Dynamic LINQ to solve this problem