[NOT] 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
Arguments
- 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.
Return Value
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.
Remarks
To specify an exclusive range, use the greater than (>) and less than (<) operators instead of BETWEEN.
Example
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:
Follow the procedure in How to: Execute a Query that Returns StructuralType Results (EntityClient).
Pass the following query as an argument to the
ExecuteStructuralTypeQuery
method:
SELECT VALUE product FROM AdventureWorksEntities.Product
AS product where product.ListPrice BETWEEN 50 AND 90
The output is shown below:
ProductID: 809
Name: ML Mountain Handlebars
ProductNumber: HB-M763
MakeFlag: True
ProductID: 812
Name: ML Road Handlebars
ProductNumber: HB-R720
MakeFlag: True
ProductID: 815
Name: LL Mountain Front Wheel
ProductNumber: FW-M423
MakeFlag: True
ProductID: 818
Name: LL Road Front Wheel
ProductNumber: FW-R623
MakeFlag: True
ProductID: 823
Name: LL Mountain Rear Wheel
ProductNumber: RW-M423
MakeFlag: True
...