The .NET Expression type has support for representing calling into a function defined by another expression, but is there a way of expressing this using the C# lambda expression syntax? I can generate one expression, compile it and call it in another expression but that loses the "expressionness" of the lambda being called, and the calling expression will only contain a reference to an anonymous compiled function.
I.e., what I want to do is something like:
Expression<Func<int, int>> f = x => x + x;
Expression<Func<int, int>> g = x => 2 + f(x);
but as it's not valid to call an Expression directly, the closest thing I have is:
Expression<Func<int, int>> f = x => x + x;
var f_ = f.Compile();
Expression<Func<int, int>> g = x => 2 + f_(x);
... which loses the fact that the function f being called is an expression.