Fabricates references to an entity in an entityset.
The entityset identifier, not a string literal.
A row-typed expression that corresponds to the key properties of the entity type.
row_typed_expression must be structurally equivalent to the key type for the entity. That is, it must have the same number and types of fields in the same order as the entity keys.
In the example below, Orders and BadOrders are both entitysets of type Order, and Id is assumed to be the single key property of Order. The example illustrates how we may produce a reference to an entity in BadOrders. Note that the reference may be dangling. That is, the reference may not actually identify a specific entity. In those cases, a
DEREF operation on that reference returns a null.
select CreateRef(LOB.BadOrders, row(o.Id)) from LOB.Orders as o
The following Entity SQL query uses the CREATEREF operator to fabricate references to an entity in an entity set. 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 Key(CreateRef(AdventureWorksEntities.Products, row(p.ProductID))) FROM AdventureWorksEntities.Products as p