代码:

public Dictionary<string, string> XXXModelColumnName
        {
            get
            {
                var dic = new Dictionary<string, string>();
                PropertyInfo[] fields = typeof(XXXModel).GetProperties();
                foreach (PropertyInfo field in fields)
                {
                    var fieldName = field.Name;
                    var displayName = field.GetCustomAttribute<DisplayNameAttribute>();
                    dic.Add(fieldName, displayName == null ? fieldName : displayName.DisplayName);
                }
                return dic;
            }
        }

 

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-24
  • 2021-06-15
  • 2022-12-23
  • 2022-03-03
相关资源
相似解决方案