예제 #1
0
        private void AdjustOutputTypes(MySqlDataReader reader)
        {
            // since MySQL likes to return user variables as strings
            // we reset the types of the readers internal value objects
            // this will allow those value objects to parse the string based
            // return values
            for (int i = 0; i < reader.FieldCount; i++)
            {
                string fieldName = reader.GetName(i);
                if (fieldName.IndexOf(StoredProcedure.ParameterPrefix) != -1)
                {
                    fieldName = fieldName.Remove(0, StoredProcedure.ParameterPrefix.Length + 1);
                }
                MySqlParameter parameter = command.Parameters.GetParameterFlexible(fieldName, true);

                IMySqlValue v = MySqlField.GetIMySqlValue(parameter.MySqlDbType);
                if (v is MySqlBit)
                {
                    MySqlBit bit = (MySqlBit)v;
                    bit.ReadAsString = true;
                    reader.ResultSet.SetValueObject(i, bit);
                }
                else
                {
                    reader.ResultSet.SetValueObject(i, v);
                }
            }
        }
        private void SetDbType(DbType db_type)
        {
            dbType = db_type;
            switch (dbType)
            {
            case DbType.Guid:
                mySqlDbType = MySqlDbType.Guid;
                break;

            case DbType.AnsiString:
            case DbType.String:
                mySqlDbType = MySqlDbType.VarChar;
                break;

            case DbType.AnsiStringFixedLength:
            case DbType.StringFixedLength:
                mySqlDbType = MySqlDbType.String;
                break;

            case DbType.Boolean:
            case DbType.Byte:
                mySqlDbType = MySqlDbType.UByte;
                break;

            case DbType.SByte:
                mySqlDbType = MySqlDbType.Byte;
                break;

            case DbType.Date:
                mySqlDbType = MySqlDbType.Date;
                break;

            case DbType.DateTime:
                mySqlDbType = MySqlDbType.DateTime;
                break;

            case DbType.Time:
                mySqlDbType = MySqlDbType.Time;
                break;

            case DbType.Single:
                mySqlDbType = MySqlDbType.Float;
                break;

            case DbType.Double:
                mySqlDbType = MySqlDbType.Double;
                break;

            case DbType.Int16:
                mySqlDbType = MySqlDbType.Int16;
                break;

            case DbType.UInt16:
                mySqlDbType = MySqlDbType.UInt16;
                break;

            case DbType.Int32:
                mySqlDbType = MySqlDbType.Int32;
                break;

            case DbType.UInt32:
                mySqlDbType = MySqlDbType.UInt32;
                break;

            case DbType.Int64:
                mySqlDbType = MySqlDbType.Int64;
                break;

            case DbType.UInt64:
                mySqlDbType = MySqlDbType.UInt64;
                break;

            case DbType.Decimal:
            case DbType.Currency:
                mySqlDbType = MySqlDbType.Decimal;
                break;

            case DbType.Object:
            case DbType.VarNumeric:
            case DbType.Binary:
            default:
                mySqlDbType = MySqlDbType.Blob;
                break;
            }
            valueObject = MySqlField.GetIMySqlValue(mySqlDbType);
        }
        private void SetMySqlDbType(MySqlDbType mysql_dbtype)
        {
            mySqlDbType = mysql_dbtype;
            valueObject = MySqlField.GetIMySqlValue(mySqlDbType);

            switch (mySqlDbType)
            {
            case MySqlDbType.Decimal:
                dbType = DbType.Decimal;
                break;

            case MySqlDbType.Byte:
                dbType = DbType.SByte;
                break;

            case MySqlDbType.UByte:
                dbType = DbType.Byte;
                break;

            case MySqlDbType.Int16:
                dbType = DbType.Int16;
                break;

            case MySqlDbType.UInt16:
                dbType = DbType.UInt16;
                break;

            case MySqlDbType.Int24:
            case MySqlDbType.Int32:
                dbType = DbType.Int32;
                break;

            case MySqlDbType.UInt24:
            case MySqlDbType.UInt32:
                dbType = DbType.UInt32;
                break;

            case MySqlDbType.Int64:
                dbType = DbType.Int64;
                break;

            case MySqlDbType.UInt64:
                dbType = DbType.UInt64;
                break;

            case MySqlDbType.Bit:
                dbType = DbType.UInt64;
                break;

            case MySqlDbType.Float:
                dbType = DbType.Single;
                break;

            case MySqlDbType.Double:
                dbType = DbType.Double;
                break;

            case MySqlDbType.Timestamp:
            case MySqlDbType.DateTime:
                dbType = DbType.DateTime;
                break;

            case MySqlDbType.Date:
            case MySqlDbType.Newdate:
            case MySqlDbType.Year:
                dbType = DbType.Date;
                break;

            case MySqlDbType.Time:
                dbType = DbType.Time;
                break;

            case MySqlDbType.Enum:
            case MySqlDbType.Set:
            case MySqlDbType.VarChar:
                dbType = DbType.String;
                break;

            case MySqlDbType.TinyBlob:
            case MySqlDbType.MediumBlob:
            case MySqlDbType.LongBlob:
            case MySqlDbType.Blob:
                dbType = DbType.Object;
                break;

            case MySqlDbType.String:
                dbType = DbType.StringFixedLength;
                break;

            case MySqlDbType.Guid:
                dbType = DbType.Guid;
                break;
            }
        }