I would like to know how to bind parameters to values within an expression tree
Something like
Expression<Func<String, String, bool>> e1 = (x,y) => x == y;
Then I would like to bind y, while preserving it as a single expression. A obvious attempt would be something like
Expresion<Func<String, bool>> e2 = x => e1(x, "Fixed Value Here");
But that would turn my expression into an Invoke node. Is there a way to simply bind a parameter within my first expression while getting the signature of the second expression?
with
this uses
ExpressionVisitor
to rebuild the expression, substitutingy
with the constant.Another approach is to use
Expression.Invoke
, but this doesn't work in all cases.