标签:
代码:
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; } }
获取实体属性名称(Property)和DisplayName属性名称(Attribute)
标签:
原文地址:http://www.cnblogs.com/talentzemin/p/5565970.html