예제 #1
0
        public static JDbClientExecutor Resolve(ENUM_DATABASE_TYPE type)
        {
            IDbConnection connection = null;

            if (type == ENUM_DATABASE_TYPE.MSSQL)
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.MSSQL);
            }
            else if (type == ENUM_DATABASE_TYPE.MYSQL)
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.MYSQL);
            }
            else if (type == ENUM_DATABASE_TYPE.POSTGRESQL)
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.POSTGRESQL);
            }
            else
            {
                throw new NotImplementedException();
            }

            var executor = new JDbClientExecutor(connection);

            return(executor);
        }
예제 #2
0
        public static JDbClientExecutor Resolve <TDatabase>()
            where TDatabase : IDbConnection
        {
            IDbConnection connection = null;

            if (typeof(TDatabase) == typeof(SqlConnection))
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.MSSQL);
            }
            else if (typeof(TDatabase) == typeof(MySqlConnection))
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.MYSQL);
            }
            else if (typeof(TDatabase) == typeof(NpgsqlConnection))
            {
                connection = JDatabaseInfo.Instance.GetConnection(ENUM_DATABASE_TYPE.POSTGRESQL);
            }
            else
            {
                throw new NotImplementedException();
            }

            var executor = new JDbClientExecutor(connection);

            return(executor);
        }