我在C#LINQ中有一个group by子句,执行时间超过5分钟。在生产环境中因大规模数据而超时。有没有办法优化这个LINQ查询?感谢任何帮助。
var qFilingReview = (from x in FilingReviewsList
group x by new { x.filingAnswer.Grouping, x.filingAnswer.Instructions, x.filingReview.Name, x.filingQuestion.Number } into grp
select new { result = grp.FirstOrDefault() })
.ToList()
.OrderBy(k => k.result.filingQuestion.Id)
.ThenByDescending(k => k.result.filingAnswer.Id);
答案 0 :(得分:3)
起初我认为你必须删除不必要的ToList()调用。