Ensure NHibernate SessionFactory is only created once
I have written an NHibernateSessionFactory class which holds a static Nhibernate ISessionFactory. This is used to make sure we only have one session factory, and the first time OpenSession() is called I create the actuall SessionFactory - next times I use the same and open a session on it. The code looks like this: public class NhibernateSessionFactory : INhibernateSessionFactory { private static ISessionFactory _sessionFactory; public ISession OpenSession() { if (_sessionFactory == null) { var cfg = Fluently.Configure(). Database(SQLiteConfiguration.Standard.ShowSql().UsingFile("Foo.db")).