title: NHibernate, dependency injection. Close ISession properly
body: <p>I am using Ninject, NHibernate, ASP.NET MVC3 and repository pattern. The module binding in Ninject is as following.</p>
  
  <pre><code>Bind&lt;ISessionFactory&gt;().ToProvider(new SessionFactoryProvider()).InSingletonScope();
  Bind&lt;ISession&gt;().ToMethod(context =&gt; context.Kernel.Get&lt;ISessionFactory&gt;().OpenSession()).InRequestScope();
  </code></pre>
  
  <p>The question is should the repository take an ISession or ISessionFactory. If it takes an ISessionFactory then in the repository I can open a session when necessary and close it after use. If it takes an ISession, the repository uses it directly. But I am wondering if the session is closed properly. </p>