예제 #1
0
        public NHibernate.Cfg.Configuration GetConfiguration()
        {
            var assemblies = GetAssemblies();

            if (_databaseProvider == null)
            {
                throw new Exception("Please set the database provider in mrcms.config");
            }

            var iPersistenceConfigurer = _databaseProvider.GetPersistenceConfigurer();
            var autoPersistenceModel   = GetAutoPersistenceModel(assemblies);

            var config = Fluently.Configure()
                         .Database(iPersistenceConfigurer)
                         .Mappings(m =>
            {
                m.AutoMappings.Add(autoPersistenceModel);
                foreach (var assembly in assemblies)
                {
                    m.FluentMappings.AddFromAssembly(assembly);
                }
            })
                         .Cache(SetupCache)
                         .ExposeConfiguration(AppendListeners)
                         .ExposeConfiguration(AppSpecificConfiguration)
                         .ExposeConfiguration(c =>
            {
#if DEBUG
                c.SetProperty(Environment.GenerateStatistics, "true");
#else
                c.SetProperty(Environment.GenerateStatistics, "false");
#endif
                c.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
                c.SetProperty(Environment.BatchSize, "25");
            })
                         .BuildConfiguration();


            _databaseProvider.AddProviderSpecificConfiguration(config);

            ValidateSchema(config);

            config.BuildMappings();

            return(config);
        }
예제 #2
0
        public NHibernate.Cfg.Configuration GetConfiguration()
        {
            List <Assembly> assemblies = GetAssemblies();


            IPersistenceConfigurer iPersistenceConfigurer = _databaseProvider.GetPersistenceConfigurer();
            AutoPersistenceModel   autoPersistenceModel   = GetAutoPersistenceModel(assemblies);

            ApplyCoreFilters(autoPersistenceModel);

            NHibernate.Cfg.Configuration config = Fluently.Configure()
                                                  .Database(iPersistenceConfigurer)
                                                  .Mappings(m => m.AutoMappings.Add(autoPersistenceModel))
                                                  .Cache(SetupCache)
                                                  .ExposeConfiguration(AppendListeners)
                                                  .ExposeConfiguration(AppSpecificConfiguration)
                                                  .ExposeConfiguration(c =>
            {
#if DEBUG
                c.SetProperty(Environment.GenerateStatistics, "true");
                c.SetProperty(Environment.ShowSql, "true");
#else
                c.SetProperty(Environment.GenerateStatistics, "false");
#endif
                c.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
                c.SetProperty(Environment.BatchSize, "25");
            })
                                                  .BuildConfiguration();


            _databaseProvider.AddProviderSpecificConfiguration(config);

            ValidateSchema(config);

            config.BuildMappings();

            return(config);
        }