BETWEEN (Entity SQL)

 

Determines whether an expression results in a value in a specified range. The Entity SQL BETWEEN expression has the same functionality as the Transact-SQL BETWEEN expression.

  
expression [ NOT ] BETWEEN begin_expression AND end_expression    

expression
Any valid expression to test for in the range defined by begin_expression and end_expression. expression must be the same type as both begin_expression and end_expression.

begin_expression
Any valid expression. begin_expression must be the same type as both expression and end_expression. begin_expression should be less than end_expression, else the return value will be negated.

end_expression
Any valid expression. end_expression must be the same type as both expression and begin_expression.

NOT
Specifies that the result of BETWEEN be negated.

AND
Acts as a placeholder that indicates expression should be within the range indicated by begin_expression and end_expression.

true if expression is between the range indicated by begin_expression and end_expression; otherwise, false. null will be returned if expression is null or if begin_expression or end_expression is null.

To specify an exclusive range, use the greater than (>) and less than (<) operators instead of BETWEEN.

The following Entity SQL query uses BETWEEN operator to determine whether an expression results in a value in a specified range. 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:

[!CODE [DP EntityServices Concepts 2#BETWEEN](../CodeSnippet/VS_Snippets_Data/dp entityservices concepts 2#between)]

Entity SQL Reference

Show: