UNION (Entity SQL)
Combines the results of two or more queries into a single collection.
expression UNION [ ALL ] expression
Any valid query expression that returns a collection to combine with the collection All expressions must be of the same type or of a common base or derived type as
Specifies that multiple collections are to be combined and returned as a single collection.
Specifies that multiple collections are to be combined and returned as a single collection, including duplicates. If not specified, duplicates are removed from the result collection.
A collection of the same type or of a common base or derived type as
UNION is one of the Entity SQL set operators. All Entity SQL set operators are evaluated from left to right. For precedence information for the Entity SQL set operators, see EXCEPT.
The following Entity SQL query uses the UNION ALL operator to combine the results of two queries into a single collection. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:
Follow the procedure in How to: Execute a Query that Returns StructuralType Results.
Pass the following query as an argument to the
(SELECT VALUE P FROM AdventureWorksEntities.Products AS P WHERE P.Name LIKE 'C%') UNION ALL (SELECT VALUE A FROM AdventureWorksEntities.Products AS A WHERE A.ListPrice > @price)