コード例 #1
0
        public static ISessionFactory InitSessionFactory(DatabaseConnection.DatabaseName databaseName, bool exposeConfiguration)
        {
            //HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            if (_factory == null)
            {
                _factory = SessionFactoryCreator.CreateSessionFactory(databaseName);
            }

            return _factory;
        }
コード例 #2
0
        public static ISessionFactory GetSessionFactory(DatabaseConnection.DatabaseName environment)
        {
            if(_sessionFactory == null)
            {
                _sessionFactory = TestSessionManager.InitSessionFactory(DatabaseConnection.DatabaseName.GenPresTest, true);
            }
            return _sessionFactory;
            //Factories.Add(environment.ToString(), SessionManager.InitSessionFactory(DatabaseConnection.DatabaseName.GenPresTest, true));
            //}

            //return Factories[environment.ToString()];
        }
コード例 #3
0
ファイル: SessionManager.cs プロジェクト: halcwb/GenPres_Old
        public static ISessionFactory InitSessionFactory(DatabaseConnection.DatabaseName databaseName, bool exposeConfiguration)
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

            if (_factory == null)
            {
                _factory = SessionFactoryCreator.CreateSessionFactory(databaseName);
            }

            var session = _factory.OpenSession();
            CurrentSessionContext.Bind(session);
            if(exposeConfiguration)
            {
                SessionFactoryCreator.BuildSchema(session);
            }
            return _factory;
        }
コード例 #4
0
        public static ISessionFactory CreateSessionFactory(DatabaseConnection.DatabaseName databaseName)
        {
            var fluentConfiguration = Fluently.Configure();

            if(databaseName == DatabaseConnection.DatabaseName.GenPresTest)
            {
                fluentConfiguration.Database(SQLiteConfiguration.Standard.InMemory().ConnectionString("Data Source=:memory:; Version=3; New=True;").Raw("connection.release_mode", "on_close").ShowSql());
            }else
            {
                fluentConfiguration.Database(SQLiteConfiguration.Standard.InMemory().ConnectionString("Data Source=:memory:; Version=3; New=True;").Raw("connection.release_mode", "on_close").ShowSql());
                //fluentConfiguration.Database(MsSqlConfiguration.MsSql2008.ConnectionString(GetConnectionString(databaseName)));
            }

            fluentConfiguration.Mappings(x => x.FluentMappings.AddFromAssemblyOf<UserMap>())
                .CurrentSessionContext<NHibernate.Context.ThreadStaticSessionContext>()
                .ExposeConfiguration(cfg => _configuration = cfg);

            _sessionFactory =  fluentConfiguration.BuildSessionFactory();

            return _sessionFactory;
        }
コード例 #5
0
 private static string GetConnectionString(DatabaseConnection.DatabaseName databaseName)
 {
     return DatabaseConnection.GetLocalConnectionString(databaseName);
 }
コード例 #6
0
ファイル: SessionManager.cs プロジェクト: halcwb/GenPres_Old
 private static ISessionFactory CreateSessionFactory(DatabaseConnection.DatabaseName databaseName, bool exposeConfiguration)
 {
     return SessionFactoryCreator.CreateSessionFactory(databaseName);
 }
コード例 #7
0
        public static string GetConnectionString(DatabaseName database, String name)
        {
            var instance = new DatabaseConnection();

            return instance.GetConnectionString(Enum.GetName(typeof(DatabaseName), database), name);
        }