我们如何最小化以下查询?

时间:2018-05-17 11:24:13

标签: entity-framework linq linq-to-entities query-performance

以下是通过异常Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.的linq查询。对于以下内容的最小化查询是什么,

return await base.Execute((dataContext) =>
            {
                var demo = (from proj in dataContext.ProjectStats
                            select new { a = proj } into sam
                            group sam by new
                            {
                                sam.a.ClassTypeID,
                                sam.a.StudentID
                            }
                 into gcs
                            select gcs.Select(x => new Dao.ProjectStat()
                            {
                                StudentID = gcs.Key.StudentID,
                                ClassTypeID = gcs.Key.ClassTypeID,
                                CompletedCount = gcs.Sum(y => y.a.CompletedCount),
                                FinishedTime = x.a.FinishedTime
                            })).SelectMany(g => g).SelectObject();
                return demo.ToList();
            });

0 个答案:

没有答案