using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CallCenter.Utility.Linq { public static class LinqExtend { public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet(); foreach (TSource element in source) { if (seenKeys.Add(keySelector(element))) { yield return element; } } } } }