假设我有3个表:Employee表、employmenthhistory表和Languages表。一个雇员可以有多种语言和工作经历。
员工ID Name Email
1 AAA aaa@gmail.com
2 BBB bbb@gmail.com
3 CCC ccc@gmail.com
工作经历
ID EmployeeID Company Position
1 1 Devon Energy aaa
2 2 Emric bbb
3 3 Capcom ccc
语言ID EmployeeID Language Level
1 1 English Expert
2 2 Dutch Expert
3 3 Franch Expert
如何使用ObjectQuery QueryBuilder应用过滤器?示例:我想过滤德文公司的员工。应该是员工"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
}
注意:我使用QueryBuilder进行高级过滤。
最诚挚的问候,布赖恩
经过1天的剧痛,我终于找到了解决办法。我使用microsoft dynamic linq提供的动态linq来解决这个问题