I'm having a headache trying to convert the following linq expression.
to the following linq expression...
In the example above the object is always of type
I know how easy it could to convert/cast between parameter types but I'm not too sure how to cast between return types.
You'll need to create a new expression by:
Expression.Convertover the source expression's body to create the result's body.
Expression<Func<T, object>> source = ... var resultBody = Expression.Convert(source.Body, typeof(U)); var result = Expression.Lambda<Func<T, U>>(resultBody, source.Parameters);