C#获取实体类属性名称
方法:
1 public static string GetPropertyName(Expression<Func<SupplierInfos, string>> expr) 2 { 3 var name = ((MemberExpression)expr.Body).Member.Name; 4 return name; 5 }
调用:
1 string SI_State = GetPropertyName(t => t.SI_State);
方法:
1 public static string GetPropertyName(Expression<Func<SupplierInfos, string>> expr) 2 { 3 var name = ((MemberExpression)expr.Body).Member.Name; 4 return name; 5 }
调用:
1 string SI_State = GetPropertyName(t => t.SI_State);