Convert a Sql query with group by clause and/or aggregate function into linq to sql?

Query #2: from adt1 in dc. AuditTable join usr in dc. UserTable on adt1.

UserName == usr. UserID group adt1 by adt1. Username int ag select new { UserName = ag.

Key, TSMax = ag. Max(ts => adt1. TimeStamp) } Why the join to the user table?

Filter?

Thanks, got there in the end, complete answer is below.. :-) – Paul Rowland Aug 7 '09 at 10:51.

I got it working... the answer was to use the let keyword. As an aside I highly recommend using LinqPad when trying to work these things out. From adt in AuditTable join usr in UserTable on adt.

UserName equals usr. User_Id group adt by new { adt. UserName, adt.

Roles, usr. First_Name, usr. Last_Name } into g let LastAccessed = g.

Max(a => a. TimeStamp) select new { UserName = g.Key. UserName, Roles = g.Key.

Roles, FirstName = g.Key. First_Name, LastName = g.Key. Last_Name, TimeStamp = LastAccessed }.

Group adt1 by adt1. Select new { UserName = ag. Key, TSMax = ag.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions