我需要按照以下方法进行操作
ExposeProperty((a) => a.Name); //not work
错误:无法使用实例引用访问成员“Account2.Name”;使用类型名称来限定它
public class Account2
{
public static string Name
{
get { return "Foo"; }
}
}
public class CustomReport<TEntity>
{
public static void ExposeProperty<TProp>(Expression<Func<TEntity, TProp>> property)
{
//...
}
public static void ExposeProperty<TProp>(Expression<Func<TProp>> property)
{
//...
}
}
public class AccountCustomReport2 : CustomReport<Account2>
{
public static void Main()
{
ExposeProperty((a) => a.Name); //not work
ExposeProperty(() => Account2.Name); //work
}
}