I have an expression tree I have created by parsing an Xml using the expression class in C#. See this question.
I only have Add, Subtract, Divide, Multiply, Parameters, And and Or in my Expression Tree. Is there a way to convert this ExpressionTree into a callable method? …or do I have to emit the IL manually?
Kind regards,
Here’s an example of both approaches. If I have missed something, or you want more information, just let me know.
Personally, I would aim towards the first method; it it both simpler and more efficient. This might involve passing the original parameter throughout a stack of nested code, but so be it. I have got some code somewhere that takes the ‘Invoke’ approach (composite), and re-writes the tree as the first approach (single) – but it is quite complex and long. But very useful for Entity Framework (which doesn’t support Expression.Invoke).