I want to find all items in one collection that do not match another collection. The collections are not of the same type, though; I want to write a lambda expression to spe
///
/// This method returns items in a set that are not in
/// another set of a different type
///
///
///
///
///
///
///
///
///
public static IEnumerable Except(
this IEnumerable items,
IEnumerable other,
Func getItemKey,
Func getOtherKey)
{
return from item in items
join otherItem in other on getItemKey(item)
equals getOtherKey(otherItem) into tempItems
from temp in tempItems.DefaultIfEmpty()
where ReferenceEquals(null, temp) || temp.Equals(default(TOther))
select item;
}
I don't remember where I found this method.