DEREF (Entity SQL)

Dereferences a reference value and produces the result of that dereference.

Syntax

SELECT DEREF ( o.expression ) FROM Table AS o;

Arguments

expression Any valid query expression that returns a collection.

Return Value

The value of the entity that is referenced.

Remarks

The DEREF operator dereferences a reference value and produces the result of that dereference. For example, if r is a reference of type ref<T>, Deref(r) is an expression of type T that yields the entity referenced by r. If the reference value is null, or is dangling (that is, the target of the reference does not exist), the result of the DEREF operator is null.

Example

The following Entity SQL query uses the DEREF operator to dereference a reference value and produce the result of that dereference. 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 DEREF(REF(p)).Name 
FROM AdventureWorksEntities.Products AS p

See also