1

Just a quick question. If I have a binding like so:

Bind<ISession>().ToMethod(context => context.Kernel.Get<ISessionManager>().GetSession()).InRequestScope();

(Assuming that ISessionManager.GetSession() returns SessionFactory.OpenSession())

Do I need to explicitly close the session? or will it automatically dispose itself when Ninject deems it out of scope?

somemvcperson
  • 1,263
  • 2
  • 18
  • 31
  • possible duplicate of [Will Ninject call dispose and close the NHibernate Isession?](http://stackoverflow.com/questions/5243228/will-ninject-call-dispose-and-close-the-nhibernate-isession) – Ruben Bartelink Jun 24 '11 at 10:00
  • not a possible, it is a duplicate... couldnt find the initial question you have posted – somemvcperson Jun 28 '11 at 21:55
  • I think the answer is here : http://stackoverflow.com/questions/5243228/will-ninject-call-dispose-and-close-the-nhibernate-isession – Tomasz Jaskuλa Jun 24 '11 at 08:09

1 Answers1

2

If ISession implements IDisposable Ninject will call it , And I think it does.

Latest Source code : http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibernate/src/NHibernate/ISession.cs?revision=5765&view=markup

Jahan Zinedine
  • 14,616
  • 5
  • 46
  • 70