title: Missing constructor in a class derrived from a generic class
body: <p>I'm trying to create a generic LINQ-TO-SQL repository based on <a href="http://kianryan.livejournal.com/33081.html" rel="nofollow noreferrer">this post</a> which basically lets you define a generic base repository class, then you can define all of your actual repository classes by deriving from the generic base.</p>
  
  <p>I want the option of using a repository with or without passing in the data context, so I decided to create two constructors in the generic base class:</p>
  
  <pre><code>  public abstract class GenericRepository&lt;T, C&gt;
          where T : class
          where C : System.Data.Linq.DataContext, new()
      {
          public C _db;
  
          public GenericRepository()
          {
              _db = new C();
          }
  
  
          public GenericRepository(C db)
          {
              _db = db;
          }
  
  
          public IQueryable&lt;T&gt; FindAll()
  
      ... and other repository functions
     }
  </code></pre>
  
  <p>To use it, I would derrive my actual repository class:</p>
  
  <pre><code>public class TeamRepository : GenericRepository&lt;Team, AppDataContext&gt; { }
  </code></pre>
  
  <p>Now, if I try to use this with a parameter:</p>
  
  <pre><code>AppDataContext db = new AppDataContext();
  TeamRepository repos=new TeamRepository(db);
  </code></pre>
  
  <p>I get the error:
     <strong>'App.Models.TeamRepository' does not contain a constructor that takes 1 arguments</strong></p>
  
  <p>So, it looks like you cant inherit constructors in C#, so, how would you code this so I can call:  TeamRepository()  or TeamRepository(db)</p>