title: Help with Windsor and Repository and Unit of Work patterns
body: <p>I have these interfaces:</p>
  
  <pre><code>public interface IUnitOfWork
  {
      IPersonRepository People { get; }
      IBookRepository Books { get; }
      int Commit();
  }
  
  public interface IBookRepository
  {
      Book GetBookById(int id);
      IQueryable&lt;Book&gt; GetAllBooks();
  }
  
  public interface IPersonRepository
  {
      Person GetPersonById(int id);
      IQueryable&lt;Person&gt; GetAllPeople();
  }
  </code></pre>
  
  <p>I implement <code>IUnitOfWork</code> as follow:</p>
  
  <pre><code>public class SqlUnitOfWork : IUnitOfWork
  {
      private readonly DbContext dbContext;
  
      public SqlUnitOfWork()
      {
          dbContext = new DbContext("name=SQLContainer");
      }
  
      public IPersonRepository People
      {
          get { return IoC.Container.Resolve&lt;IPersonRepository&gt;(new { DbContext = dbContext }); }
      }
  
      public IBookRepository Books
      {
          get { return IoC.Container.Resolve&lt;IBookRepository&gt;(new { DbContext = dbContext }); }
      }
  
      public int Commit()
      {
          return dbContext.SaveChanges();
      }
  }
  </code></pre>
  
  <p>The implementations of <code>IBookRepository</code> and <code>IPersonRepository</code> uses a constructor that takes a <code>DbContext</code> as a parameter, and this DbContext is created in the SqlUnitOfWork (code above) and I pass this parameter using an overload of the Resolve method.</p>
  
  <p>My question is, is this the right way to do it? Is this a good practice?</p>
  
  <p>Thanks!</p>