Imagine table History:
public class History
{
public int Id { get; set; }
public int UserId { get; set; }
public int ItemId { get; set; }
public DateTime Date { get; set; }
}
The data looks like this:
1|10|4|2009-01-20
2|11|2|2009-01-22
3|10|4|2009-01-28 // same userId and itemId as id=1, but newer date
4|11|2|2009-01-26 // same userId and itemId as id=2, but newer date
5|10|8|2009-01-14 // is already the latest date, no duplicate userId, and ItemId combination
6|12|9|2009-01-11 // is already the latest date, no duplicate userId, and ItemId combination
should become:
3|10|4|2009-01-28
4|11|2|2009-01-26
5|10|8|2009-01-14
6|12|9|2009-01-11
How can I do this using Linq lambda to objects expressions?
It is similar to this question, but you also need to check where UserId and ItemId are the same.