My application uses NHibernate with a session-by-request implementation. I have a core library that provides a thread safe singleton to access the current nhibernate session.
This singleton is used from a web application in the BeginRequest and EndRequest events to ensure that a session is opened and closed with each request. In addition, my DataAccess layer uses the same singleton to access data, so it uses the same nhibernate session.
Now I have added Ninject to the equation so that I can display the NHibernate contextual information, namely the connection string, at run time. I would like to change the value in my web configuration, which tells which database it will go to. The problem is that for this I need my singleton (mentioned above) in order to be able to display one of its properties, IConnectionStringProvider.
It is correctly connected, but the singleton will never have the created properties, therefore, everything breaks.
So, to my question ... how can I get Ninject to work with singleton or how can I change my implementation to work with Ninject?
ctorx source
share