https://stackoverflow.com/questions/489258/linqs-distinct-on-a-particular-property Also part of: https://github.com/morelinq/MoreLINQ
public static class LINQExtension
{
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;
}
}
}
}