Exemplo n.º 1
0
        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>();
            }
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     if (!AppConfig.Loaded)
     {
         AppConfig.Load(ConfigFactory.CreateXmlConfig());
     }
     _emit = CoreFactory.CreateDialectProvider("dest").CreateMappingSQLEmit(CoreFactory.ObjectMapInfoCache);
 }
Exemplo n.º 3
0
        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>();
            }
        }