Is there a better way to get the Property name when passed in via a lambda expression? Here is what i currently have.
eg.
GetSortingInfo
I leave this function if you want to get multiples fields:
///
/// Get properties separated by , (Ex: to invoke 'd => new { d.FirstName, d.LastName }')
///
///
///
///
public static string GetFields(Expression> exp)
{
MemberExpression body = exp.Body as MemberExpression;
var fields = new List();
if (body == null)
{
NewExpression ubody = exp.Body as NewExpression;
if (ubody != null)
foreach (var arg in ubody.Arguments)
{
fields.Add((arg as MemberExpression).Member.Name);
}
}
return string.Join(",", fields);
}