How to get the Value in [Display(Name="")] attribute in Controller for any property using EF6
This should work:
MemberInfo property = typeof(ABC).GetProperty(s);
var dd = property.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute;
if(dd != null)
{
var name = dd.Name;
}
You can use it:
MemberInfo property = typeof(ABC).GetProperty(s);
var name = property.GetCustomAttribute<DisplayAttribute>()?.Name;