다음을 통해 공유


THEN (Entity SQL)

The result of a WHEN clause when it evaluates to true.

WHEN when_expression THEN then_expression

Arguments

  • when_expression
    Any valid Boolean expression.
  • then_expression
    Any valid query expression that returns a collection.

Remarks

If when_expression evaluates to the value true, the result is the corresponding then-expression. 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 (Entity SQL).

Example

The following Entity SQL query uses the CASE expression to evaluate a set of Boolean expressions. 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 PrimitiveType Results (EntityClient).

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

CASE WHEN AVG({25,12,11}) < 100 THEN TRUE ELSE FALSE END

This example produces the following output:

Value: True

See Also

Reference

WHEN (Entity SQL)
CASE (Entity SQL)

Concepts

Entity SQL Reference

Other Resources

Case Expression