ObjectQuery<T>::Distinct Method ()

 

Limits the query to unique results.

Namespace:   System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public:
ObjectQuery<T>^ Distinct()

Return Value

Type: System.Data.Objects::ObjectQuery<T>^

A new ObjectQuery<T> instance that is equivalent to the original instance with SELECT DISTINCT applied.

This query builder method returns an ObjectQuery<T> instance that is equivalent to the original query with SELECT DISTINCT applied.

The DISTINCT operator cannot be applied to an object that includes a mapping to a non-comparable column in the data source (such as ntext).

The example in this topic is based on the AdventureWorks Sales Model. The example uses UnionAll method to create a new ObjectQuery<T> object. Then it calls Distinct on the new ObjectQuery<T> object to get the unique results of this query.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.5
Return to top
Show: