Exemplo n.º 1
0
        public InMemoryNHibernateSessionSource(IEnumerable <Assembly> mappingAssemblies)
        {
            var configuration = new Configuration();

            configuration.DataBaseIntegration(cfg =>
            {
                cfg.ConnectionString = "FullUri=file:memorydb.db?mode=memory&cache=shared";
                cfg.Driver <SQLite20Driver>();
                cfg.Dialect <SQLiteDialect>();
                cfg.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                cfg.SchemaAction       = SchemaAutoAction.Update;
            });

            configuration.AddCodeMappingsFromAssemblies(mappingAssemblies);

            SchemaMetadataUpdater.QuoteTableAndColumns(configuration);

            _factory = configuration.BuildSessionFactory();

            _connectionCreatingSessionThatShouldNotBeDisposedUntilTestHasRunToEnd = _factory.OpenSession();
            _connection = _connectionCreatingSessionThatShouldNotBeDisposedUntilTestHasRunToEnd.Connection;

            new SchemaExport(configuration).Execute(
                script: false,
                export: true,
                justDrop: false,
                connection: _connection,
                exportOutput: null);
        }
Exemplo n.º 2
0
        public SqlServerNHibernateSessionSource(string connectionString, IEnumerable <Assembly> mappingAssemblies)
        {
            var configuration = new Configuration();

            configuration.DataBaseIntegration(cfg =>
            {
                cfg.ConnectionString = connectionString;
                cfg.Driver <Sql2008ClientDriver>();
                cfg.Dialect <MsSql2008Dialect>();
                cfg.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                cfg.SchemaAction       = SchemaAutoAction.Update;
            });

            configuration.AddCodeMappingsFromAssemblies(mappingAssemblies);

            SchemaMetadataUpdater.QuoteTableAndColumns(configuration);

            _factory = configuration.BuildSessionFactory();
        }