title: Ninject And Connection Strings
body: <p>I am very new to Ninject and am trying Ninject 2 with MVC and Linq. I have a SqlProductRepository class and all I want to know is what's the best way of passing the connectionstring in the constructor if I am injecting the Repository object in the controller.  </p>
  
  <pre><code>public class SqlProductRepository:IProductRepository
  {
      private Table&lt;Product&gt; productsTable;
  
      public SqlProductRepository(string connectionString)
      {
        productsTable = (new DataContext(connectionString)).GetTable&lt;Product&gt;();   
      }
  
      public IQueryable&lt;Product&gt; Products
      {
          get { return productsTable; }
      }
  }
  </code></pre>
  
  <p>This is my ProductController class where I am injecting the Repository:</p>
  
  <pre><code>  public class ProductsController : Controller
  {
      private int pageSize = 4;
      public int PageSize { get { return pageSize; } set { pageSize = value; } }  
  
      IProductRepository _productsRepository;
  
      [Inject]
      public ProductsController(IProductRepository productRepository)
      {
          _productsRepository = productRepository;
      }
  
      public ViewResult List(int page)
      {
          return View(_productsRepository.Products
                                         .Skip((page - 1) * pageSize)
                                         .Take(pageSize)
                                         .ToList()
                      );
      }
  }
  </code></pre>
  
  <p>Can somebody please guide me regarding this? </p>