title: How to get the Value in [Display(Name="")] attribute in Controller for any property using EF6
body: <p>I am developing an MVC 5 application. I want to get the value in  <strong>[Display(Name = "")]</strong> attribute in my controller method for any property of any class.</p>
  
  <p>My model is as:</p>
  
  <pre><code>public partial class ABC
  {
     [Required]
     [Display(Name = "Transaction No")]
     public string S1 { get; set; }
  }
  </code></pre>
  
  <p>I have looked <a href="https://stackoverflow.com/questions/5015830/get-the-value-of-displayname-attribute">answer to this question</a>, but it is a little lengthy procedure. I am looking for something readily available and built-in.</p>
  
  <p>So, I have tried this:</p>
  
  <pre><code>MemberInfo property = typeof(ABC).GetProperty(s); // s is a string type which has the property name ... in this case it is S1
  var dd = property.CustomAttributes.Select(x =&gt; x.NamedArguments.Select(y =&gt; y.TypedValue.Value)).OfType&lt;System.ComponentModel.DataAnnotations.DisplayAttribute&gt;();
  </code></pre>
  
  <p>But I have 2 problems, First I am not getting the value i.e. "Transaction No". And secondly even though I have mentioned <strong>.OfType&lt;></strong> I am still getting all attributes i.e. [Display(Name="")] and [Required].</p>
  
  <p>But luckily I am getting the "Transaction No" value in </p>
  
  <blockquote>
    <p>property>>CustomAttribute>>[1]>>NamedArguments>>[0]>>TypedValue>>Value
    = "Transaction No"</p>
  </blockquote>
  
  <p>Since <strong>TypedValue.Value</strong> has the required value, So how can I retrieve it?</p>