I am trying to call String.Format from the Linq.Expression tree. Here is a quick example:
var format = Expression.Constant("({0}) {1}"); var company = Expression.Property(input, membernames.First()); var project = Expression.Property(input, membernames.Last()); var args = new Expression[] {format, company, project}; var invoke = Expression.Call(method,args);
However, the problem is that String.Format has a signature:
String.Format(string format, params object[] args)
and I'm trying to pass Expression [].
Now I could solve all the problems of creating an array by filling it with the results of my expressions, but I really want the result to be as follows:
String.Format("({0}) {1}", input.foo, input.bar)
How do I access the params function using Linq expressions?
source share