Question

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 aaa@gmail.com
2   BBB bbb@gmail.com
3   CCC ccc@gmail.com

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top