Expression trees work very similarly to C# code: there all the statements inside a block (delimited by {}
) are executed in order. So, that's exactly how Expression.Block()
is evaluated too: all the expressions in its Expressions
collection are evaluated in order. If you want to have a ConditionalExpression
inside the block, then you shouldn't put them directly into the block (unless you also want them evaluated separately, outside of the ConditionalExpression
).
Which Expression trees to be included in a block expression
-
17-06-2023 - |
Question
I'm confused on which expression trees need to be added to a blockexpression when wanting code to be executed.
For example, if I have ConditionalExpression, that has a reference to an IsTrue and IsFalse. Do I need to include the expressions that are for IsTrue and IsFalse. or just the Conditional Expression?
Is there a guideline, i.e. how do the IEnumerable of Expressions get executed? Do they get executed in the order they appear in the IEnumerable?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow