-
Couldn't load subscription status.
- Fork 3.3k
Description
Some nested CASE blocks, e.g.:
CASE
WHEN (condition1)
THEN
CASE
WHEN (condition2)
THEN result1
ELSE result2
END
ELSE result2
ENDcan be optimized to:
CASE
WHEN condition1 AND condition2
THEN result1
ELSE result2
ENDIn practice we get those kinds of chained CASE blocks in the following scenarios:
context.Set<Product>().OrderBy(p => p.UnitsInStock > 10 ? p.ProductID > 40 : p.ProductID <= 40)