title: Many repositories in one controller and initializing the database connection
body: <p>I want to use Repository Pattern (I know that I can use Unit of Work Pattern but I would like to use Repository Pattern here). So in each repository class I have queries for a specific table, for example:</p>
  
  <pre><code>public class NotesRepository : INotesRepository, IDisposable
  {
      private DatabaseContext context;
  
      public NotesRepository(DatabaseContext context)
      {
          this.context = context;
      }
  
      public IQueryable&lt;Notes&gt; GetAllNotes()
      {
          return (from x in context.Notes
                  select x);
      }
  }
  </code></pre>
  
  <p>And another repository example:</p>
  
  <pre><code>public class CommentsRepository : ICommentsRepository, IDisposable
  {
      private DatabaseContext context;
  
      public CommentsRepository(DatabaseContext context)
      {
          this.context = context;
      }
  
      public IQueryable&lt;Comments&gt; GetAllComments()
      {
          return (from x in context.Comments
                  select x);
      }
  }
  </code></pre>
  
  <p>Now I would like to use these two repositories in one controller. So with the Repository Pattern I initialize the database connection in the controller constructor and pass it to each repository, am I right? For example:</p>
  
  <pre><code>public class HomeController : Controller
  {
      private INotesRepository NotesRepository;
      private ICommentsRepository CommentsRepository;
  
      public HomeController()
      {
          DatabaseContext db = new DatabaseContext();
  
          this.NotesRepository = new NotesRepository(db);
          this.CommentsRepository = new CommentsRepository(db);
      }
  
      // ........
  }
  </code></pre>