Returns distinct elements from a sequence by using the default equality comparer to compare values.


public static IBindableQuery<TSource> Distinct<TSource>(this IBindableCollection<TSource> source) 
    where TSource : class
public static IBindableQuery<TSource> Distinct<TSource>(this IBindableCollection<TSource> source, IEqualityComparer<TSource> comparer) 
    where TSource : class


An IBindableCollection that contains distinct elements from the source sequence.


  • source: The sequence to remove duplicate elements from. Source elements must be reference types.
  • comparer: An IEqualityComparer to compare values.


  • ArgumentNullException when source is null.


IBindableCollection<Customer> distinctCustomers = customers.AsBindable().Distinct();

Differences with LINQ to Objects

In LINQ to Objects, the Distinct operation iterates the source, and yields items that have not already been yeilded as deemed by the equality comparer. Since LINQ to Objects provides a one-off evaluation, items that are not yielded can simply be discarded. By contrast, in Bindable LINQ, items that have already been yielded are kept. If the yielded instance is removed from the underlying collection, items that would otherwise have been discarded will take its place.

Last edited Jun 2, 2008 at 4:21 PM by stovellp, version 4


No comments yet.