public static ISessionFactory InitSessionFactory(DatabaseConnection.DatabaseName databaseName, bool exposeConfiguration) { //HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize(); if (_factory == null) { _factory = SessionFactoryCreator.CreateSessionFactory(databaseName); } return _factory; }
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()]; }
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; }
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; }
private static string GetConnectionString(DatabaseConnection.DatabaseName databaseName) { return DatabaseConnection.GetLocalConnectionString(databaseName); }
private static ISessionFactory CreateSessionFactory(DatabaseConnection.DatabaseName databaseName, bool exposeConfiguration) { return SessionFactoryCreator.CreateSessionFactory(databaseName); }
public static string GetConnectionString(DatabaseName database, String name) { var instance = new DatabaseConnection(); return instance.GetConnectionString(Enum.GetName(typeof(DatabaseName), database), name); }