/// <summary> /// Removes a set of objects from a collection based on a specific property value /// </summary> /// <typeparam name="T">The collection type</typeparam> /// <typeparam name="TValue">The type of the property to compare</typeparam> /// <param name="source">The source collection</param> /// <param name="second">The collection of objects to be excluded</param> /// <param name="projection">The selector function for the distinction property</param> /// <returns>The collection without the specified elements</returns> public static IEnumerable <T> Except <T, TValue>(this IEnumerable <T> source, IEnumerable <T> second, Func <T, TValue> projection) { return(source.Except(second, GenericEqualityComparer <T> .Create(projection))); }
/// <summary> /// Determines object distinction purely based on a specified property (i.e. not object equality comparison) /// </summary> /// <typeparam name="T">The collection type</typeparam> /// <typeparam name="TValue">The type of the property to compare</typeparam> /// <param name="source">The source collection</param> /// <param name="projection">The selector function for the distinction property</param> /// <returns>The distinct collection</returns> public static IEnumerable <T> Distinct <T, TValue>(this IEnumerable <T> source, Func <T, TValue> projection) { return(source.Distinct(GenericEqualityComparer <T> .Create(projection))); }