Export (0) Print
Expand All

ObjectQuery<T>::UnionAll Method

Combines the results of the query with the results of another object query, including all duplicates.

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

public:
ObjectQuery<T>^ UnionAll(
	ObjectQuery<T>^ query
)

Parameters

query
Type: System.Data.Objects::ObjectQuery<T>
An ObjectQuery<T> that represents the results to add.

Return Value

Type: System.Data.Objects::ObjectQuery<T>
A new ObjectQuery<T> instance that is equivalent to the original instance with UNION ALL applied to add the results of the specified query.

ExceptionCondition
ArgumentNullException

The query parameter is nullptr.

UnionAll adds the results of the supplied query including all duplicates.

The supplied query that defines results to add must be of the same type or of a type that can be promoted to the type of this ObjectQuery<T>. For example, the following is valid because DiscontinuedProducts can be promoted to Products:

ObjectQuery<Product>.Union(ObjectQuery<DiscontinuedProduct>)

The following will throw an exception because Products cannot be promoted to DiscontinuedProducts.

ObjectQuery <DiscontinuedProduct>.Union(ObjectQuery<Product>) 

For an ObjectQuery<T> of type DbDataRecord, the records in both queries must have the same number of columns, and the types in the columns of the DbDataRecord of the passed query must be promotable to the types of the columns in the DbDataRecord of 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 (Entity Framework).

The resulting query inherits the connection from the ObjectQuery<T> instance on which UnionAll was called.

The example in this topic is based on the Adventure Works Sales Model. The example uses the UnionAll method to create a new ObjectQuery<T> object. Then it calls the Distinct method 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

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft