LINQ group by and getting latest value
Posted
by gregmac
on Stack Overflow
See other posts from Stack Overflow
or by gregmac
Published on 2010-04-17T05:50:25Z
Indexed on
2010/04/17
5:53 UTC
Read the original article
Hit count: 331
Say I have a structure like:
class SomeObject
Public Name as String
Public Created as Date
...
end class
I have a List(of SomeObject), which has multiple entries for each name with different times. I'd like to select the newest (largest Created value) object for each Name.
Given:
Name Created
A 2010-04-16 *
A 2010-04-15
B 2010-04-12
B 2010-04-13 *
C 2010-04-16 *
I'd like to pick the objects with the * beside them.
Is this possible using LINQ?
© Stack Overflow or respective owner