title: Generic Method Constraint of child class issue
body: <p>First here's the break down of the class hierarchy:</p>
  <pre><code>public class Entity {
  }
  
  public abstract class AuditBase&lt;T&gt; {
     protected abstract void SomeMethod();
  }
  
  public class EntityAudit : AuditBase&lt;Entity&gt; {
     protected override void SomeMethod() {
     }
  }
  </code></pre>
  <p>Then, I have a method with a constraint like so:</p>
  <pre><code>public async Task&lt;IEnumerable&lt;T&gt;&gt; Query&lt;T&gt;(int id) where T : AuditBase&lt;T&gt;
  {
    var instance = Activator.CreateInstance&lt;T&gt;();
    var refTable = instance.RefTable;
  
    var collection = _context.Database.GetCollection&lt;T&gt;(&quot;Audit&quot;);
    var filter = String.Join(&quot;{ RefTable: '&quot;, refTable, &quot;', Object: { Id: {'$eq': &quot;, id.ToString(), &quot;} } }&quot;);
  
    return await collection.FindSync&lt;T&gt;(filter).ToListAsync();
  }
  </code></pre>
  <p>However, I get an error when I use the following code:</p>
  <pre><code>var result = await Query&lt;EntityAudit&gt;(5);
  </code></pre>
  <p>The error is:</p>
  <pre><code>The type 'EntityAudit' cannot be used as type parameter 'T' in the generic type of method 'Audit.Query&lt;T&gt;(int)'. There is no implicit reference conversion from 'EntityAudit' to 'AuditBase&lt;EntityAudit&gt;'.
  </code></pre>
  <p>I kind of understand the issue.  My goal is really to restrict the returned <code>IEnumerable</code> to <em>only</em> contain objects that are <strong>children of</strong> <code>AuditBase</code>.  Currently, it's trying to return items of type 'Entity' due to <code>T</code>.</p>
  <p>I can't do the constraint as so: <code>... where T: Audit</code> as <code>Audit</code> &quot;requires one parameter.&quot;</p>
  <p>Any thoughts?  How do I implement the constraint?</p>
  <h3>EDIT:</h3>
  <p>So I ended up doing the following:</p>
  <pre><code>public async Task&lt;IEnumerable&lt;T&gt;&gt; Query&lt;T,U&gt;(int id) where T: AuditBase&lt;U&gt;
  {
    ...
  }
  
  var result = await Query&lt;EntityAudit, Entity&gt;(5)
  </code></pre>
  <p>This works.</p>
  <p><strong>But, is there a better way?</strong></p>