我有一个问题:
from m in dc.ReportingMonths
where m.Month.Value == month
select (from k in m.KPI_Actives
where k.DateActive.Year == year
select (from r in dc.ReportingViews
where r.KPIID == k.KPIID select r)
);
显然,因为它是嵌套的 LINQ 查询 - 每个返回一个 IQueryable,结果我得到一组 IQueryable。
我如何编写一个类似的查询,而不是只返回一个简单的 ReportingView 列表(如最后一个查询返回的那样),而不使用 foreach 循环来创建一个新列表?
谢谢!
最佳答案
类似于:
from m in dc.ReportingMonths where m.Month.Value == month
from k in m.KPI_Actives
where k.DateActive.Year == year
from r in dc.ReportingViews
where r.KPIID == k.KPIID
select r;
?
关于c# - LINQ 查询返回列表列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3102326/