我想根据包含的表过滤我的 LINQ 查询,但遇到了一些麻烦。
这是原始声明,它有效:
return
this.ObjectContext.People.
Include("Careers").
Include("Careers.Titles").
Include("Careers.Titles.Salaries");
现在我正在尝试使用投影过滤来过滤职业,但遇到了麻烦。它编译但它遗漏了 Titles 和 Salaries 表,这会导致运行时错误,我似乎无法将这些表重新添加:
var query1 = (
from c in
this.ObjectContext.People.
Include("Careers").
Include("Careers.Titles").
Include("Careers.Titles.Salaries")
select new
{
c,
Careers = from Careers in c.Careers
where Careers.IsActive == true
select Careers
});
var query = query1.AsEnumerable().Select(m => m.c);
return query.AsQueryable();
如何在过滤后的查询中包含职称和薪水表?