Udostępnij za pośrednictwem


REF

Returns a reference to an entity instance.

REF( expression ) 

Arguments

  • expression
    Any valid expression that yields an instance of an entity type.

Return Value

A reference to the specified entity instance.

Remarks

An entity reference consists of the entity key and an entity set name. Because different entity sets can be based on the same entity type, a particular entity key can appear in multiple entity sets. However, an entity reference is always unique. If the input expression represents a persisted entity, a reference to this entity will be returned. If the input expression is not a persisted entity, a null reference will be returned.

If the property extraction operator (.) is used to access a property of an entity, the reference is automatically dereferenced.

Example

The following Entity SQL query uses the REF operator to return the reference for an input entity argument. The same query dereferences the reference because we are using a property extraction operation (.) to access a property of the Product entity. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:

  1. Follow the procedure in How to: Execute a Query that Returns PrimitiveType Results.

  2. Pass the following query as an argument to the ExecutePrimitiveTypeQuery method:

SELECT VALUE REF(p).Name FROM AdventureWorksEntities.Products as p

See Also

Reference

DEREF
CREATEREF
KEY

Concepts

Entity SQL Reference
Type Definitions