I have a table with 2 keys; ID column and version number. I am trying to select "only the latest version" of entries.
I am trying to use the LINQ expression style to get GROUP BY, and pull the total value of MAX for Version. However, aggregation does not occur .
Generalized code:
From C In Credentials Group Join .... Group Join .... Group C.CredentialID, NE.ClientID, C.Version By NE.ClientID, C.CredentialID Into CGroup = Group From CG In CGroup Select New With { .ClientID = CG.ClientID, .CredentialID = CG.CredentialID, .MaxVersion = CGroup.Max(Function(p) p.Version) }
Actual Results:
ClientID CredentialID MaxVersion 1196 1 3 1196 1 3 1196 1 3 1196 2 1
Desired Results:
ClientID CredentialID MaxVersion 1196 1 3 1196 2 1
Also tried the same results:
Group C By Key = New With {Key NE.ClientID, Key C.CredentialID} Into CGroup = Group From CG In CGroup Select New With { .ClientID = Key.ClientID, .CredentialID = Key.CredentialID, .MaxVersion = CGroup.Max(Function(p) p.Version) }
I am looking for a solution that does not include creating custom classes with the appropriate properties and custom sort / group functions and does not use lambda expressions in the tail of the request.
Thanks!
source share