title: Is there a way to check how many of a certain attribute there are in a model?
body: <p>I have the following model:</p>
  <pre><code>[Key]
  public string Id { get; set; }
      
  [IsSearchable]
  public string Code{ get; set; }
      
  [IsSearchable]
  public string Name { get; set; }
      
  [IsSearchable]
  public string Address { get; set; }
      
  [IsSearchable]
  public string PostCode { get; set; }  
          
  [IsFilterable]
  public int? Setting{ get; set; }
      
  [IsFilterable, IsSortable]
  public Location Location { get; set; }
  
  </code></pre>
  <p>I am comparing a model in a database with the above one, and want to check that the database model has the same attributes. Is there any way to find out the specific number of attributes without having to hard code them in? For example, this is the method I've written to check:</p>
  <pre><code>private bool CheckAttributeEquality(List&lt;PropertyInfo&gt;searchableAttributeProperties,
                     List&lt;PropertyInfo&gt; filterableAttributeProperties,
                     List&lt;PropertyInfo&gt; sortableAttributeProperties,
                     List&lt;PropertyInfo&gt; keyAttributeProperties)
  {
      if (searchableAttributeProperties.Count == 4 &amp;&amp;
          filterableAttributeProperties.Count == 2 &amp;&amp;
          sortableAttributeProperties.Count == 1 &amp;&amp;
          keyAttributeProperties.Count == 1)
      {
          return true;
      }
  
      return false;
  }
  </code></pre>
  <p>However I don't want to hard code these in, I want to make sure they match the attributes on my model? Can anyone help?</p>