IN (Entity SQL)

Determines whether a value matches any value in a collection.

Syntax

value [ NOT ] IN expression  

Arguments

value
Any valid expression that returns the value to match.

[ NOT ]
Specifies that the Boolean result of IN be negated.

expression
Any valid expression that returns the collection to test for a match. All expressions must be of the same type or of a common base or derived type as value.

Return Value

true if the value is found in the collection; null if the value is null or the collection is null; otherwise, false. Using NOT IN negates the results of IN.

Example

The following Entity SQL query uses the IN operator to determine whether a value matches any value in a collection. 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.

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

SELECT VALUE product FROM AdventureWorksEntities.Products 
    AS product WHERE product.ListPrice IN {125, 300}

See also