0

I had a similar situation as the OP here: how do I query sql for a latest record date for each user

The accepted answer worked for me, but now I need to implement the same thing in Linq to SQL in ASP.NET. How is this accomplished?

Community
  • 1
  • 1
Mark13426
  • 2,569
  • 6
  • 41
  • 75

1 Answers1

0

you can use it as follows

from t in Users
join tm in Users
on t.UserName equals tm.UserName
where t.Date == (Users.Where(a=>a.UserName == t.UserName).Select(b=>b.Date)).Max()
group t by new
   {
       t.UserName,
       t.Date,
       t.Value
    } into g   
select new 
    {
      g.Key.UserName,
      g.Key.Date,
      g.Key.Value
     }
Usman
  • 3,200
  • 3
  • 28
  • 47