Revision: 15112
Updated Code
at June 24, 2009 12:19 by jmcd
Updated Code
var valueFromSomewhere = "BAR"; Expression<Func<Controller, string, object>> expressionWithArg = (c, s) => c.Action("foo", s); var methodCallExpression = (MethodCallExpression)expressionWithArg.Body; var expressionWithoutArg = Expression.Lambda<Func<Controller, object>>( Expression.Call(methodCallExpression.Object, methodCallExpression.Method, methodCallExpression.Arguments[0], Expression.Constant(valueFromSomewhere)), expressionWithArg.Parameters[0] );
Revision: 15111
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 24, 2009 12:18 by jmcd
Initial Code
Expression<Func<Controller, string, object>> expressionWithArg = (c, s) => c.Action("foo", s); var methodCallExpression = (MethodCallExpression)expressionWithArg.Body; var expressionWithoutArg = Expression.Lambda<Func<Controller, object>>( Expression.Call(methodCallExpression.Object, methodCallExpression.Method, methodCallExpression.Arguments[0], Expression.Constant(arg)), expressionWithArg.Parameters[0] );
Initial URL
Initial Description
Initial Title
Narrowing an expression to use a delegate with fewer args
Initial Tags
Initial Language
C#