title: Introducing Generic Types to a constructor inheriting from non-Generic class
body: <h2><em>Question:</em></h2>
  
  <p>Is there a work around to be able to use generics in the constructor of a class that inherits from a class that doesn't have generic types defined?</p>
  
  <hr>
  
  <h2><em>Explanation:</em></h2>
  
  <p>I am creating a new custom attribute inheriting from the ValidationAttribute class. I want to use generic types in the constructor as seen below:</p>
  
  <pre><code>DateValidationAttribute : ValidationAttribute {
  
     public void DateValidationAttribute &lt;TData&gt;(Expression&lt;Func&lt;TData, DateTime?&gt;&gt; property){ ... }
  
  }
  </code></pre>
  
  <p>However, this doesn't seem to be allowed as the TData and TProperty generic types aren't recognized as generics. In addition I cannot define the generics in the class definition as it inherits from the ValidationAttribute class. The error I get is that TData and TProperty is not defined.</p>
  
  <hr>
  
  <h2><em>Goal:</em></h2>
  
  <p>The goal of passing and expression down to have a strongly typed way of passing attribute names. I am writing this attribute to compare two properties of a class. The implementation below is what it looks like. Beneath that is how I want the implementation to look like:</p>
  
  <pre><code>Current:
  
  public DateTime? ToDate { get; set; }
  
  [DateValidation("ToDate")]
  public DateTime? FromDate { get; set; }
  </code></pre>
  
  <hr>
  
  <pre><code>Goal:
  
  public DateTime? ToDate { get; set; }
  
  [DateValidation(prop =&gt; prop.ToDate)]
  public DateTime? FromDate { get; set; }    
  </code></pre>