I have the following items in a list:
Date Amount AnId AnotherId MainDate
2013/01/10 1000 1 5 2013/01/12
2013/01/11 2000 2 5 2013/01/12
2013/01/15 4000 1 5 2013/01/12
I want to use linq to return the following:
Date Amount AnId AnotherId MainDate
2013/01/11 2000 2 5 2013/01/12
2013/01/15 4000 1 5 2013/01/12
i.e. for a specific MainDate
, I only want the latest items that are unique across AnId
and anotherId
. So, the item on 2013/01/10 is removed as there is an item for the same MainDate
, AnId
and AnotherId
that has a date that is later than the items date...
I've been trying to Group By MainDate
and Then By AnId
and AnotherId
and OrderByDescending and then select the first item for each group, but not too clued up on linq, so i'm struggling...