You cannot use switch, you need a construct that returns a value (the switch does not return a value in C #), for example, a ternary operator<cond> ? <trueValue> : <falseValue> .
You can invest them, it will be a little dirty, but it should work.
cond1 ? valueFor1 :
(cond2 ? valueFor2 :
(cond3 ? valueFor3 :
defaultValue))
but in the where clause it is usually easier to combine your conditions with &&and ||.
source
share