Created
July 18, 2012 20:36
-
-
Save samandmoore/3138725 to your computer and use it in GitHub Desktop.
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
public static DefaultSort GetDefaultSort<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression, SortDirection direction) | |
{ | |
return new DefaultSort(EvaluateExpression(expression), direction); | |
} | |
private static string EvaluateExpression(LambdaExpression expression) | |
{ | |
var memberExpression = expression.Body as MemberExpression; | |
return memberExpression == null ? null : memberExpression.Member.Name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment