Udostępnij za pośrednictwem


[NOT] EXISTS (Entity SQL)

Determines if a collection is empty.

[NOT] EXISTS ( expression )

Arguments

  • expression
    Any valid expression that returns a collection.
  • NOT
    Specifies that the result of EXISTS be negated.

Return Value

true if the collection is not empty; otherwise, false.

Remarks

EXISTS is one of the Entity SQL set operators. All Entity SQL set operators are evaluated from left to right. For precedence information for the Entity SQL set operators, see EXCEPT (Entity SQL).

Example

The following Entity SQL query uses the EXISTS operator to determine whether the collection is empty. 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 StructuralType Results (EntityClient).

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

select VALUE name from AdventureWorksEntities.Product 
    AS name where exists(SELECT A from AdventureWorksEntities.Product 
    as A where A.ListPrice < 20)

See Also

Concepts

Entity SQL Reference

Other Resources

Set Operators