ObjectQuery<T>::Except Method (ObjectQuery<T>^)
Limits the query results by excluding results based on the results of another object query.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
Parameters
- query
-
Type:
System.Data.Objects::ObjectQuery<T>^
An ObjectQuery<T> that represents the results to exclude from the query.
Return Value
Type: System.Data.Objects::ObjectQuery<T>^A new ObjectQuery<T> instance that is equivalent to the original instance with EXCEPT applied based on the specified query.
| Exception | Condition |
|---|---|
| ArgumentNullException | The query parameter is null or an empty string. |
The supplied query that defines results to exclude must be of the same type or of a type that is compatible with the ObjectQuery<T>.
Parameters that are defined in the supplied query are merged with parameters that are defined in the ObjectQuery<T> instance. Parameters must be unique in the combined ObjectParameterCollection. There cannot be two parameters in the combined collection with the same name. For more information, see Query Builder Methods.
The resulting query inherits the connection from the ObjectQuery<T> instance on which Except was called.
This example is based on the AdventureWorks Sales Model. The example uses Except method to create a new ObjectQuery<T> object and then iterates through the result of the new query.
Available since 3.5