Can anyone help me with the equivalent LINQ query for the SQL below?
I am new to LINQ
Select * From Students_History SH
Where SH.Active = 1 and SH.ModifiedAt in (
select MAX(SH1.ModifiedAt)from Students_History SH1
group by SH1.StudentId)
This is what I have tried
var q =
from h in Students_History
where h.Active=1
group h by h.StudentId into g
select new
{
StudentID = g.Key,
LatestModified = g.Max (x => x.ModifiedAt)
}
This linq query does not give me the right result and somehow the active=1 is ignored
I have about dozen fields in my Students_History table and I want all those fields not just studentId and ModifiedAt.
Try this: