m-u
8/18/2016 - 1:05 PM

Action Name strings to Expression Func - get the method name by using a better way instead of hard-coding strings names for actions

Action Name strings to Expression Func - get the method name by using a better way instead of hard-coding strings names for actions

Expression<Func<ProductController, ActionResult>> add = (p => p.Add(null));

Expression<Func<ProductController, ActionResult>> edit = (p => p.Edit(null));

var action = (Id == 0) ? add : edit;

string actionMethodName = ((MethodCallExpression)action.Body).Method.Name;