方法一的调用如下:
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);
}
方法一的调用如下:
new Expression<Func<T, object>>[] {x => x.Parent.Parent.Parent.Name,x => x.Parent.Parent.Parent.Name}
//方法二:
protected List<string> GetPropertyNames<T>(Expression<Func<T, object>>[] expression)
{
return ReflectionHelper.GetPropertyNamesFromExpressions(expression);
}
方法二的写法能否更加省略啊,new Expression<Func<T, object>>[]这个每次下太麻烦了,可否有另外的简单的写法,求解
代码有点儿乱,没看懂