public static void Map<T>(Expression<Func<T, object >> expression)
{
var memberExpression = (expression.Body as UnaryExpression).Operand as MemberExpression;
var name = memberExpression.Member.Name;
}
Usage:
Map<Article>(x => x.Name)
Name is of type string.
How do I get the type?
I assume you want the return type. If you want the type on which the method is defined, use
memberExpression.Member.DeclaringType.