Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Evaluates one or more Boolean expressions.
WHEN when_expression THEN then_expression
Arguments
- when_expression
Any valid Boolean expression.
- then_expression
Any valid query expression that returns a collection.
Return Type
A Boolean value.
Remarks
Use WHEN to evaluate one or more Boolean expressions. If there are multiple when_expressions, the first when_expression that evaluates to true yields the corresponding Then_expression. The remaining expressions are not evaluated. If none of the WHEN conditions are satisfied, the else-expression is evaluated. However, if there is no else-expression, the result is null.
For an example, see CASE.
Example
The following Entity SQL query uses the CASE expression to evaluate a set of Boolean expressions in order to determine the result. 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 PrimitiveType Results.
Pass the following query as an argument to the
ExecutePrimitiveTypeQuery
method:
CASE WHEN AVG({@score1,@score2,@score3}) < @total THEN TRUE ELSE FALSE END