逆向工程一些包含错误数据的报告。使用Linq在Asp.Net C#中编写的报表
我可以在数据库中编写查询,但在转换为Linq时遇到问题。
public StudentBehaviourActivityDTO GetStudentBehaviourActivity(
Guid userId)
{
List<DateTime> lastUpdatedDates = Uow.ActivityTrackingUnitValues
.Where(atuv => atuv.Last_Updated_On != null
&& atuv.TBH_Activity_Tracking_Unit
.StudentBehaviour
.Student
.TeamMembers
.Any(tm => tm.Id == userId))
.Select(atuv => (DateTime)DbFunctions
.TruncateTime(atuv.Last_Updated_On))
.ToList();
在toList中加载的是什么?我假设这是在装入我的表: ActivityTrackingUnitValues
但是它也这样做了,看起来它也在连接这些表
.StudentBehaviour
.Student
.TeamMembers
我想取Last_Updated_On的最大值,然后按学生分组
任何帮助或解释都非常感谢。
发布于 2018-09-18 06:49:54
public StudentBehaviourActivityDTO GetStudentBehaviourActivity(
Guid userId)
{
List<DateTime> lastUpdatedDates = Uow.ActivityTrackingUnitValues
.Where(atuv => atuv.Last_Updated_On != null // check to make sure it's not null
&& atuv.TBH_Activity_Tracking_Unit
.StudentBehaviour //this references a class (generally a join, but it doesn't join!)
.Student //this references a class (generally a join, but it doesn't join!)
.TeamMembers //this references a class (generally a join, but it doesn't join!)
.Any(tm => tm.Id == userId)) // Checks to make sure it isn't null or has a count greater than 0
.Select(atuv => (DateTime)DbFunctions
.TruncateTime(atuv.Last_Updated_On)) // Returns the truncatedtime and nowthing else
.ToList(); // converts it to a list
据我所知,这是为了确保这个类有可用的成员。
https://stackoverflow.com/questions/52376220
复制相似问题