Hi All,
I have a method to Generate Expression By Clause as below:
internal static Expression<Func<TModel, T>> GenExpressionByClause<TModel, T>(string column)
{
PropertyInfo columnPropInfo = typeof(TModel).GetProperty(column);
var entityParam = Expression.Parameter(typeof(TModel), "e"); // {e}
var columnExpr = Expression.MakeMemberAccess(entityParam, columnPropInfo); // {e.column}
var lambda = Expression.Lambda(columnExpr, entityParam) as Expression<Func<TModel, T>>; // {e => e.column}
return lambda;
}
So I could build lambda expression as e=>e.column
.
but I want to change it to e=>string.Format("{0}",e.column)
. How could I refactor the code?