public void set_repository() { NHibernateSessionFactoryBuilder session_factory_builder = new NHibernateSessionFactoryBuilder(configuration); Configuration cfg = null; ISessionFactory factory = session_factory_builder.build_session_factory(x => { cfg = x; }); repository = new Repository(factory, cfg); }