Esempio n. 1
0
 private static void Initialization(SessionFactoryParameters parameters, Configuration configuration)
 {
     if (parameters.CreateDatabase) {
         var export = new SchemaExport(configuration);
         export.Execute(false/*script*/, true/*export*/, false/*justDrop*/);
     }
     else if (parameters.UpdateSchema) {
         var update = new SchemaUpdate(configuration);
         update.Execute(false/*script*/, true /*doUpdate*/);
     }
 }
Esempio n. 2
0
        public ISessionFactory BuildSessionFactory(SessionFactoryParameters parameters)
        {
            var database = GetPersistenceConfigurer(parameters.CreateDatabase);
            var persistenceModel = CreatePersistenceModel(parameters.RecordDescriptors);

            var sessionFactory = Fluently.Configure()
                .Database(database)
                .Mappings(m => m.AutoMappings.Add(persistenceModel))
                .ExposeConfiguration(config => Initialization(parameters, config))
                .BuildSessionFactory();

            return sessionFactory;
        }
 public ISessionFactory BuildSessionFactory(SessionFactoryParameters parameters)
 {
     AbstractBuilder builder;
     if (isProviderNameMatching(parameters, "SQLite")) {
         builder = new SQLiteBuilder(parameters.DataFolder, parameters.ConnectionString);
     }
                 else if (isProviderNameMatching(parameters, "SQLServer")) {
         builder = new SqlServerBuilder(parameters.DataFolder, parameters.ConnectionString);
     }
                 else {
                     builder = loadBuilderByReflectionOrFail(parameters.Provider);
                 }
     return builder.BuildSessionFactory(parameters);
 }
 public ISessionFactory BuildSessionFactory(SessionFactoryParameters parameters) {
     var builder = new TraceEnabledBuilder(parameters.DataFolder, parameters.ConnectionString);
     return builder.BuildSessionFactory(parameters);
 }
 private bool isProviderNameMatching(SessionFactoryParameters parameters, string providerNameToMatch)
 {
     return string.Equals(parameters.Provider, providerNameToMatch, StringComparison.InvariantCultureIgnoreCase);
 }
			public void ShouldBlowWhenProviderTypeHasNoParameterlessConstructor() {
				var recordDescriptors = new[] { new RecordTopology { TableName = "Hello", Type = typeof(FooRecord) } };
				var parameters =
					new SessionFactoryParameters
					{
						ConnectionString = "q"
						, UpdateSchema = true
						, Provider = typeof(BuilderWithNoParameterlessConstructor).AssemblyQualifiedName
						, RecordDescriptors = recordDescriptors
					};
				ISessionFactoryBuilder manager = new SessionFactoryBuilder();
				var expectedOrchardException = Assert.Throws<OrchardException>(() => manager.BuildSessionFactory(parameters));
				Assert.IsTrue(expectedOrchardException.Message.Contains(parameters.Provider));
				Assert.IsNotNull(expectedOrchardException.InnerException);
			}