Sdílet prostřednictvím


OVERLAPS

Determines whether two collections have common elements.

expression OVERLAPS expression

Arguments

  • expression
    Any valid query expression that returns a collection to compare with the collection returned from another query expression. All expressions must be of the same type or of a common base or derived type as expression.

Return Value

true if the two collections have common elements; otherwise, false.

Remarks

OVERLAPS provides functionally equivalent to the following:

EXISTS ( expression INTERSECT expression )

OVERLAPS 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.

Example

The following Entity SQL query uses the OVERLAPS operator to determines whether two collections have a common value. The query is based on the AdventureWorks Sales Model. To compile and run this, follow these steps:

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

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

SELECT value P from AdventureWorksEntities.Products 
    as P WHERE ((select P from AdventureWorksEntities.Products 
    as P WHERE P.ListPrice > @price1) overlaps (select P from
    AdventureWorksEntities.Products as P WHERE P.ListPrice < @price2))

See Also

Concepts

Entity SQL Reference