c# List unique linq code example
Example 1: C# .NET Core linq Distinct
var distinctUsers = allUsers
.GroupBy(x => x.UserId)
.Select(x => x.First())
.ToList();
Example 2: c# linq select only unique values from list
var uniq = allvalues.GroupBy(x => x.Id).Select(y=>y.First()).Distinct();
Example 3: c# linq select only unique values from list
var uniqueCategories = repository.GetAllProducts()
.Select(p=>p.Category)
.Distinct();