Last active
August 18, 2016 13:07
-
-
Save umair-me/091f5b3771885f42cac5990cc0d6a05f to your computer and use it in GitHub Desktop.
Action Name strings to Expression Func - get the method name by using a better way instead of hard-coding strings names for actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment