I have List collection of Message objects.
public class Message
{
public int Id {get; set; }
public string Body{ get; set; }
public string Sender { get; set; }
public DateTime Timestamp { get; set; }
}
I want to get only one message with most recent Timestamp for each sender. How do I do it using LINQ?
Pravesh Singh
18-Aug-2014var q = from n in table
group n by n.Senderinto g
select g.OrderByDescending(t=>t.Timestamp).FirstOrDefault();