title: Ninject and Request Scope For Connection
body: <p>Will request scope tied to my DatabaseFactory release my database connection after the request is finished?</p>
  
  <pre><code>kernel.Bind&lt;IDatabaseFactory&gt;().To&lt;DatabaseFactory&lt;MySqlConnection&gt;&gt;().InRequestScope().WithConstructorArgument("connectionString", Config.Data.MySQLConnection);
  
  
  public class DatabaseFactory&lt;T&gt; : Disposable, IDatabaseFactory where T : IDbConnection, new()
      {
          private readonly string _connectionString;
          private  IDbConnection _dataConnection;
  
          public DatabaseFactory(string connectionString)
          {
              _connectionString = connectionString;
          }
  
          #region IDatabaseFactory Members
  
          public IDbConnection Get()
          {
              return _dataConnection ?? (_dataConnection = new T { ConnectionString = _connectionString });
          }
  
          #endregion
  
          protected override void DisposeCore()
          {
              if (_dataConnection != null)
                  _dataConnection.Dispose();
          }
  }
  </code></pre>