Läs på engelska

Dela via


DEREF (Entity SQL)

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

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, ifris a reference of type ref<T>, Deref (r) is an expression of typeTthat 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 (EntityClient).

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

SELECT VALUE DEREF(REF(p)).Name FROM AdventureWorksEntities.Product 
    as p

The output is shown below:

Value: Adjustable Race
Value: All-Purpose Bike Stand
Value: AWC Logo Cap
Value: BB Ball Bearing
Value: Bearing Ball

See Also

Reference

REF (Entity SQL)
CREATEREF (Entity SQL)
KEY (Entity SQL)

Concepts

Entity SQL Reference
Nullable Structured Types (Entity SQL)

Other Resources

Reference Operators