Linq Distinct ExtensionMethod

    public static class ExtensionMethods
    {
        public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector)
        {
            var seenKeys = new HashSet();
            return source.Where(element => seenKeys.Add(keySelector(element)));
        }
    }
Can be used like so...
var distinctTaxTypes = (from dtt in dataSource select dtt).DistinctBy(p => p.Product.VatCodeID);