方法一的调用如下:
var propertyName = GetPropertyName<Category>(x => x.Parent.Parent.Parent.Name);
那方法二该怎么调用呢 ?就是参数(Expression<Func<T, object>>[] )该怎么传啊 ?
方法一:
protected string GetPropertyName<T>(Expression<Func<T, object>> expression)
{
return ReflectionHelper.GetPropertyNameFromExpression(expression);
}
//方法二:
protected List<string> GetPropertyNames<T>(Expression<Func<T, object>>[] expression)
{
return ReflectionHelper.GetPropertyNamesFromExpressions(expression);
}
}
}
namespace SomeNamespace
{
public class Category
{
public Categories CategoryId { get; set; }
public Category Parent { get; set; }
public string Name { get; set; }
}
public enum Categories
{
Books = 1,
Movies = 2
}
}
一只名叫tom的猫
慕妹3146593
宝慕林4294392