ROW (Entity SQL)
Constructs anonymous, structurally typed records from one or more values.
ROW ( expression [ AS alias ] [,...] )
Any valid query expression that returns a value to construct in a row type.
Specifies an alias for the value specified in a row type. If an alias is not provided, Entity SQL tries to generate an alias based on the Entity SQL alias generation rules.
A row type.
You use row constructors in the Entity SQL to construct anonymous, structurally typed records from one or more values. The result type of a row constructor is a row type whose field types correspond to the types of the values that were used to construct the row. For example, the following expression constructs a value of type
Record(a int, b string, c int).
ROW(1 AS a, "abc" AS b, a+34 AS c)
If you do not provide an alias for an expression in a row constructor, the Entity Framework will try to generate one. For more information, see the "Aliasing Rules" section of the Identifiers topic.
The following rules apply to expression aliasing in a row constructor:
Expressions in a row constructor cannot refer to other aliases in the same constructor.
Two expressions in the same row constructor cannot have the same alias.
For more information about query constructors, see Constructing Types.
The following Entity SQL query uses the ROW operator to construct anonymous, structurally typed records. 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 ROW (product.ProductID as ProductID, product.Name as ProductName) FROM AdventureWorksEntities.Products AS product