OVERLAPS (Entity SQL)

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 (Entity SQL).

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 (EntityClient).

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

SELECT value P from AdventureWorksEntities.Product 
    as P where ((select P from AdventureWorksEntities.Product 
    as P where P.ListPrice > 13) overlaps (select P from
    AdventureWorksEntities.Product as P where P.ListPrice < 20))

The output is shown below:

ProductID: 1
Name: Adjustable Race
ProductNumber: AR-5381
MakeFlag: False
ProductID: 2
Name: Bearing Ball
ProductNumber: BA-8327
MakeFlag: False
ProductID: 3
Name: BB Ball Bearing
ProductNumber: BE-2349
MakeFlag: True
ProductID: 4
Name: Headset Ball Bearings
ProductNumber: BE-2908
MakeFlag: False
ProductID: 316
Name: Blade
ProductNumber: BL-2036
MakeFlag: True
...

See Also

Concepts

Entity SQL Reference

Other Resources

Set Operators