Example #1
0
 public NHibernateSessionFactory(IPersistenceConfiguration persistenceConfiguration, INHibernatePersistenceModel nHibernatePersistenceModel)
 {
     _sessionFactory = Fluently.Configure()
                       .Database(persistenceConfiguration.GetConfiguration())
                       .Mappings(m => m.AutoMappings.Add(nHibernatePersistenceModel.GetPersistenceModel()))
                       .BuildSessionFactory();
 }
Example #2
0
        ISessionFactory CreateSessionFactory()
        {
            Initializers.Each(x => x.BeforeInitialization());

            var configuration = Fluently.Configure()
                                .ProxyFactoryFactory <DefaultProxyFactoryFactory>()
                                .Database(_persistenceConfiguration.GetConfiguration())
                                .Mappings(_persistenceModel.AddMappings);

            configuration.ExposeConfiguration(c => Initializers.Each(x => x.Configuring(c)));

            var actualConfiguration = configuration.BuildConfiguration();

            Initializers.Each(x => x.Configured(actualConfiguration));

            _sessionFactory = configuration.BuildSessionFactory();

            Initializers.Each(x => x.Initialized(actualConfiguration, _sessionFactory));

            return(_sessionFactory);
        }