I\'m building a LINQ expression tree but it won\'t compile because allegedly the local variable $var1
is out of scope:
variable \'\' of t
Your'e adding the Expression.Variable
to the list of "normal" expressions in the block - you should use the overload which specifies the variables do declare for the block separately:
Expression finalExpression = Expression.Block(new[] { resultVariable },
expressions);
(And remove the call to expressions.Add(resultVariable);
)