I want to execute two expressions for the final expression
Expression<Func<T, string>>
So, I created the expression belwo code works fine only for string types. If I get a MemberExpression expression as an Int32 or DateTime throw exception
An expression of type "System.Int32" cannot be used for a parameter of type "System.String" of the method "System.String Concat (System.String, System.String)"
If I transform the expression as
var conversion = Expression.Convert(memberExpression, typeof (string));
The receipt of a coercion statement is not defined between the types System.Int32 and System.String.
Please help me decide
code
MethodInfo bodyContactMethod = typeof (string).GetMethod("Concat",new[] {typeof (string), typeof (string)}); ParameterExpression parameter = Expression.Parameter(typeof (T)); body = Expression.Call(bodyContactMethod, cons, memberExpression); return Expression.Lambda<Func<T, string>>(body, parameter);
source share