Sunday, July 27, 2014

Is it ideal to keep one ISessionFactory open for a long life in an NHibernate application?

A friend gave me a link to this and it suggests as much. I have been opening and then disposing of a ISessionFactory every time go to the database not unlike a particular session, but I am learning that this is expensive! Perhaps a better way to go is to populate some static state for ISessionFactory at Application_Start() in Global.asax.cs and then use the singleton to get sessions in repositories.

No comments:

Post a Comment