When I try to decompile code with dotPeek, i get this:
public static Expression<Func<TInput, object>> ToUntypedPropertyExpression<TInput, TOutput>(this Expression<Func<TInput, TOutput>> expression)
{
string name = (expression.Body as MemberExpression ?? ((UnaryExpression) expression.Body).Operand as MemberExpression).Member.Name;
ParameterExpression parameterExpression;
return Expression.Lambda<Func<TInput, object>>((Expression) Expression.Convert((Expression) Expression.Property((Expression) parameterExpression, name), typeof (object)), new ParameterExpression[1]
{
parameterExpression
});
}
But when I want to copy this to another class, outside the dll, it fails. (because it says that the parameterExpression is empty). Can someone help me rewrite this so it works?
Try putting in the second line (the one with ParameterExpression parameterExpression;
)
ParameterExpression parameterExpression = expression.Parameters[0];
And all the (Expression)
casts are useless. You can remove them.