예제 #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
        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
 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);
        }