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?
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?
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
}