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();
More Related Contents:
- Linq select objects in list where exists IN (A,B,C)
- Check if all items are the same in a List
- Get a list of distinct values in List
- Increase c# list performance
- Convert List to List
- Using LINQ to remove elements from a List
- Distinct by property of class with LINQ [duplicate]
- List of Timezone IDs for use with FindTimeZoneById() in C#?
- Split a List into smaller lists of N size [duplicate]
- Convert a list to a string in C#
- Shorter syntax for casting from a List to a List?
- export to Excel from a list with EPPLUS
- Databinding to List – See changes of data source in ListBox, ComboBox
- List thread safety
- LINQ to SQL and a running total on ordered results
- How to easily initialize a list of Tuples?
- How to initialize a List to a given size (as opposed to capacity)?
- Find the most occurring number in a List
- sort string-numbers [duplicate]
- Intelligent way of removing items from a List while enumerating in C#
- Fastest way to Remove Duplicate Value from a list by lambda
- Difference between Select and ConvertAll in C#
- C# list.Orderby descending
- ArgumentOutOfRangeException on initialized List
- Code equivalent to the ‘let’ keyword in chained LINQ extension method calls
- How to sort list of Ip Addresses using c#
- WPF Filter a ListBox
- Linq OrderBy against specific values
- What is the best way to check two List lists for equality in C#
- Eliminate consecutive duplicates of list elements