使用group by获取linq中的变量计数时出错

我有一个linq查询来获取测试数量的计数。我正在使用分组和计数,但出现错误

    var response = from st in students
           join c in classes on st.id equals c.studentid
           join sd in subjectDetails on sd.classId equals c.id && sd.studentid equals c.studentid
           group st.id,st.Name,c.Class,sd.Tests into res
           select new StudentResponse
               {
                 StudentName = res.key.Name,StudentClass = res.key.Class
                 StudentGrades = new List<StudentGrades> 
                 {
                    NumberOfTests = res.Count(x => x.Tests != ""),// I am getting an error here
                    Subject = res.Key.OperationName,TotalMarks = res.Sum(x => x.ItemsCount)
                 }
                }).ToListAsync();

错误:

  

无法翻译,将在本地进行评估。”。通过将事件ID'RelationalEventId.QueryClientEvaluationWarning'传递到'DbContext.Onconfiguring

中的'ConfigureWarnings'方法,可以抑制或记录此异常。

如何获取分组依据的测试数?

ptxncxf 回答:使用group by获取linq中的变量计数时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3149827.html

大家都在问