Select distinct by two properties in a list

LINQ to Objects doesn’t provide this functionality easily in a built-in way, but MoreLINQ has a handy DistinctBy method:

messages = messages.DistinctBy(m => new { m.id, m.date }).ToList();

Leave a Comment