本文介绍了LINQ子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在LINQ中编写它?

SELECT ClassStudentID,ClassID,StudentID,CompletionDate
FROM TrainingClassStudents
WHERE(CompletionDate IN
(SELECT MAX(CompletionDate) )AS Expr1
来自TrainingClassStudents AS TrainingClassStudents_1
GROUP BY StudentID))

。员工。

How do I write this in LINQ?

SELECT     ClassStudentID, ClassID, StudentID, CompletionDate
FROM         TrainingClassStudents
WHERE     (CompletionDate IN
                          (SELECT     MAX(CompletionDate) AS Expr1
                            FROM          TrainingClassStudents AS TrainingClassStudents_1
                            GROUP BY StudentID))

Thanx.

推荐答案

var results = from maxCD in
                   ( from tc in TrainingClassStudents
                            group tc.CompletionDate by tc.StudentID into tcs
                            select tcs.Max())
                   from traCS in TrainingClassStudents
                   where traCS.CompletionDate = maxCD
                   select new {
                   traCS.ClassStudentID, traCS.ClassID, traCS.StudentID, traCS.CompletionDate };



谢谢,
Vijay Pandurangan


Thanks,
Vijay Pandurangan


这篇关于LINQ子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 06:26