Expression of type ‘System.Int32’ cannot be used for return type ‘System.Object’

Have you tried using Expression.Convert? That will add the boxing/lifting/etc conversion.

Expression conversion = Expression.Convert(expression, typeof(object));
func = Expression.Lambda<Func<T, Object>>(conversion, parameterExpression).Compile();

Leave a Comment

File not found.