private static IDatabase _OpenDatabase(string databaseId) { try { var info = ORMConfig.ORMConfiguration.GetDatabaseInfo(databaseId); IDbConnection cnn = CoreFactory.CreateDbProvider(databaseId).CreateConnection(info.ConnectString); ISQLExecutor exe = new SQLExecutor(databaseId, cnn); IObjectMapInfoCache cache = CoreFactory.ObjectMapInfoCache; var dialect = CoreFactory.CreateDialectProvider(databaseId); IModelSQLEmit emit = dialect.CreateModelSQLEmit(cache); IMetaQuery meta = dialect.CreateMetaQuery(exe); if (cnn.State != ConnectionState.Open) { cnn.Open(); } return(new Database(exe, emit, meta)); } catch (Exception ex) { throw ex.CreateWrapException <SessionException>(); } }
private static ISession _OpenSession(string databaseId) { try { var info = ORMConfig.ORMConfiguration.GetDatabaseInfo(databaseId); IDbConnection cnn = CoreFactory.CreateDbProvider(databaseId).CreateConnection(info.ConnectString); ISQLExecutor exe = new SQLExecutor(databaseId, cnn); IObjectMapInfoCache cache = CoreFactory.ObjectMapInfoCache; IEntityManager mgr = new EntityManager(exe, CoreFactory.CreateDialectProvider(databaseId).CreateMappingSQLEmit(cache)); IEntityQuery qry = new EntityQuery(exe, CoreFactory.CreateDialectProvider(databaseId).CreateQuerySQLEmit(cache)); INativeSQL native = new NativeSQL(exe); if (cnn.State != ConnectionState.Open) { cnn.Open(); } return(new SimpleSession(exe, mgr, qry, native)); } catch (Exception ex) { throw ex.CreateWrapException <SessionException>(); } }