상속: Orchard.Data.Providers.DataServiceParameters
        public Configuration BuildConfiguration(SessionFactoryParameters parameters) {
            var database = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors);

            return Fluently.Configure()
                .Database(database)
                .Mappings(m => m.AutoMappings.Add(persistenceModel))
                .BuildConfiguration();
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters)
        {
            var database         = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors);

            return(Fluently.Configure()
                   .Database(database)
                   .Mappings(m => m.AutoMappings.Add(persistenceModel))
                   .BuildConfiguration());
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters) {
            var database = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            return Fluently.Configure()
                .Database(database)
                .Mappings(m => m.AutoMappings.Add(persistenceModel))
                .ExposeConfiguration(cfg => cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] { new OrchardLoadEventListener() })
                .BuildConfiguration()
                ;
        }
예제 #4
0
        public Configuration BuildConfiguration(SessionFactoryParameters parameters)
        {
            var database         = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            return(Fluently.Configure()
                   .Database(database)
                   .Mappings(m => m.AutoMappings.Add(persistenceModel))
                   .ExposeConfiguration(cfg => cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] { new OrchardLoadEventListener() })
                   .BuildConfiguration()
                   );
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters)
        {
            var database         = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            var config = Fluently.Configure();

            foreach (var c in parameters.Configurers.OfType <ISessionConfigurationEventsWithParameters>())
            {
                c.Parameters = parameters;
            }

            parameters.Configurers.Invoke(c => c.Created(config, persistenceModel), Logger);

            config = config.Database(database)
                     .Mappings(m => m.AutoMappings.Add(persistenceModel))
                     .ExposeConfiguration(cfg => {
                cfg
                .SetProperty(NHibernate.Cfg.Environment.FormatSql, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, Hbm2DDLKeyWords.None.ToString())
                .SetProperty(NHibernate.Cfg.Environment.PropertyBytecodeProvider, "lcg")
                .SetProperty(NHibernate.Cfg.Environment.PropertyUseReflectionOptimizer, Boolean.TrueString)
                .SetProperty(NHibernate.Cfg.Environment.QueryStartupChecking, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.ShowSql, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.StatementFetchSize, "100")
                .SetProperty(NHibernate.Cfg.Environment.UseProxyValidator, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.UseSqlComments, Boolean.FalseString)
                .SetProperty(NHibernate.Cfg.Environment.WrapResultSets, Boolean.TrueString)
                .SetProperty(NHibernate.Cfg.Environment.BatchSize, "256")
                ;

                cfg.EventListeners.LoadEventListeners     = new ILoadEventListener[] { new OrchardLoadEventListener() };
                cfg.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[0];
                cfg.EventListeners.PreLoadEventListeners  = new IPreLoadEventListener[0];

                // don't enable PrepareSql by default as it breaks on SqlCe
                // this can be done per driver by overriding AlterConfiguration
                AlterConfiguration(cfg);

                parameters.Configurers.Invoke(c => c.Building(cfg), Logger);
            })
            ;

            parameters.Configurers.Invoke(c => c.Prepared(config), Logger);

            return(config.BuildConfiguration());
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters) {
            var database = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            var config = Fluently.Configure();

            foreach (var c in parameters.Configurers.OfType<ISessionConfigurationEventsWithParameters>()) {
                c.Parameters = parameters;
            }

            parameters.Configurers.Invoke(c => c.Created(config, persistenceModel), Logger);

            config = config.Database(database)
                           .Mappings(m => m.AutoMappings.Add(persistenceModel))
                           .ExposeConfiguration(cfg => {
                               cfg
                                    .SetProperty(NHibernate.Cfg.Environment.FormatSql, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, Hbm2DDLKeyWords.None.ToString())
                                    .SetProperty(NHibernate.Cfg.Environment.PropertyBytecodeProvider, "lcg")
                                    .SetProperty(NHibernate.Cfg.Environment.PropertyUseReflectionOptimizer, Boolean.TrueString)
                                    .SetProperty(NHibernate.Cfg.Environment.QueryStartupChecking, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.ShowSql, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.StatementFetchSize, "100")
                                    .SetProperty(NHibernate.Cfg.Environment.UseProxyValidator, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.UseSqlComments, Boolean.FalseString)
                                    .SetProperty(NHibernate.Cfg.Environment.WrapResultSets, Boolean.TrueString)
                                    .SetProperty(NHibernate.Cfg.Environment.BatchSize, "256")
                                    ;

                               cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] { new OrchardLoadEventListener() };
                               cfg.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[0];
                               cfg.EventListeners.PreLoadEventListeners = new IPreLoadEventListener[0];

                               // don't enable PrepareSql by default as it breaks on SqlCe
                               // this can be done per driver by overriding AlterConfiguration
                               AlterConfiguration(cfg);

                               parameters.Configurers.Invoke(c => c.Building(cfg), Logger);

                           })
                           ;

            parameters.Configurers.Invoke(c => c.Prepared(config), Logger);

            return config.BuildConfiguration();
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters) {
            var database = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            var config = Fluently.Configure();

            parameters.Configurers.Invoke(c => c.Created(config, persistenceModel), Logger);

            config = config.Database(database)
                           .Mappings(m => m.AutoMappings.Add(persistenceModel))
                           .ExposeConfiguration(cfg => {
                               cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] {new OrchardLoadEventListener()};
                               parameters.Configurers.Invoke(c => c.Building(cfg), Logger);
                           });

            parameters.Configurers.Invoke(c => c.Prepared(config), Logger);

            return config.BuildConfiguration();
        }
예제 #8
0
        public static void RunWithSqlServer(IEnumerable<RecordBlueprint> recordDescriptors, Action<ISessionFactory> action) {
            var temporaryPath = Path.GetTempFileName();
            if (File.Exists(temporaryPath))
                File.Delete(temporaryPath);
            Directory.CreateDirectory(temporaryPath);
            var databasePath = Path.Combine(temporaryPath, "Orchard.mdf");
            var databaseName = Path.GetFileNameWithoutExtension(databasePath);
            try {
                // create database
                if (!TryCreateSqlServerDatabase(databasePath, databaseName))
                    return;

                var meta = new Meta<CreateDataServicesProvider>((dataFolder, connectionString) =>
                    new SqlServerDataServicesProvider(dataFolder, connectionString),
                    new Dictionary<string, object> { { "ProviderName", "SqlServer" } });

                var manager = (IDataServicesProviderFactory)new DataServicesProviderFactory(new[] { meta });

                var parameters = new SessionFactoryParameters {
                    Provider = "SqlServer",
                    DataFolder = temporaryPath,
                    ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFileName=" + databasePath + ";Integrated Security=True;User Instance=True;",
                    RecordDescriptors = recordDescriptors,
                };

                var configuration = manager
                    .CreateProvider(parameters)
                    .BuildConfiguration(parameters);

                new SchemaExport(configuration).Execute(false, true, false);

                using (var sessionFactory = configuration.BuildSessionFactory()) {
                    action(sessionFactory);
                }
            }
            finally {
                try {
                    Directory.Delete(temporaryPath, true);
                }
                catch (IOException) { }
            }
        }
        public Configuration BuildConfiguration(SessionFactoryParameters parameters)
        {
            var database         = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors.ToList());

            var config = Fluently.Configure();

            parameters.Configurers.Invoke(c => c.Created(config, persistenceModel), Logger);

            config = config.Database(database)
                     .Mappings(m => m.AutoMappings.Add(persistenceModel))
                     .ExposeConfiguration(cfg => {
                cfg.EventListeners.LoadEventListeners = new ILoadEventListener[] { new OrchardLoadEventListener() };
                parameters.Configurers.Invoke(c => c.Building(cfg), Logger);
            });

            parameters.Configurers.Invoke(c => c.Prepared(config), Logger);

            return(config.BuildConfiguration());
        }
예제 #10
0
        public static void RunWithSqlCe(IEnumerable<RecordBlueprint> recordDescriptors, Action<ISessionFactory> action) {
            var temporaryPath = Path.GetTempFileName();
            if (File.Exists(temporaryPath))
                File.Delete(temporaryPath);
            Directory.CreateDirectory(temporaryPath);
            var databasePath = Path.Combine(temporaryPath, "Orchard.mdf");
            var databaseName = Path.GetFileNameWithoutExtension(databasePath);
            var parameters = new SessionFactoryParameters {
                Provider = "SqlCe",
                DataFolder = temporaryPath,
                RecordDescriptors = recordDescriptors
            };
            try {
                var manager = (IDataServicesProviderFactory)new DataServicesProviderFactory(new[] {
                new Meta<CreateDataServicesProvider>(
                    (dataFolder, connectionString) => new SqlCeDataServicesProvider(dataFolder, connectionString),
                    new Dictionary<string, object> {{"ProviderName", "SqlCe"}})
            });

                var configuration = manager
                    .CreateProvider(parameters)
                    .BuildConfiguration(parameters);

                configuration.SetProperty("connection.release_mode", "on_close");

                new SchemaExport(configuration).Execute(false, true, false);

                using (var sessionFactory = configuration.BuildSessionFactory()) {
                    action(sessionFactory);
                }

            }
            finally {
                try {
                    Directory.Delete(temporaryPath, true);
                }
                catch (IOException) { }
            }
        }