Answered by : kevin-wilson
var distinctUsers = allUsers .GroupBy(x => x.UserId) .Select(x => x.First()) .ToList();
Source : | Last Update : Tue, 07 Jul 20
Answered by : raksha-deshmukh
var distValues = objList.Select(o=>o.typeId).Distinct().ToList();
Source : | Last Update : Thu, 11 Feb 21
Answered by : courageous-cowfish-2tw1b4660v1n
SELECT DISTINCT ma_colonne
FROM nom_du_tableau
Source : https://sql.sh/cours/distinct | Last Update : Tue, 10 Mar 20
Answered by : abuzar-gashtasebi
List<Person> distinctPeople = allPeople .GroupBy(p => new {p.PersonId, p.FavoriteColor} ) .Select(g => g.First()) .ToList();
Source : https://stackoverflow.com/questions/489258/linqs-distinct-on-a-particular-property | Last Update : Sun, 26 Apr 20
Answered by : hungry-hamster
SELECT DISTINCT Column_name FROM table_name;
Source : | Last Update : Tue, 21 Apr 20
Answered by : phipi
var uniquePeople = from p in people group p by new {p.ID} //or group by new {p.ID, p.Name, p.Whatever} into mygroup select mygroup.FirstOrDefault();
Source : https://stackoverflow.com/questions/489258/linqs-distinct-on-a-particular-property | Last Update : Mon, 18 Jan 21
Answered by : mr-robot
public static IQueryable<ProdType> GetDistinctProdType( this IQueryable<ProdInfo> query, int categoryId)
{ return (from p in query where p.CatID == categoryId select p.Type).Distinct();
}
Source : https://stackoverflow.com/questions/5144409/linq-distinct | Last Update : Thu, 12 Mar 20
Answered by : abuzar-gashtasebi
public static IEnumerable<TSource> DistinctBy<TSource, TKey> (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{ HashSet<TKey> seenKeys = new HashSet<TKey>(); foreach (TSource element in source) { if (seenKeys.Add(keySelector(element))) { yield return element; } }
}
Source : https://stackoverflow.com/questions/489258/linqs-distinct-on-a-particular-property | Last Update : Sun, 26 Apr 20