Esempio n. 1
0
 public static MySqlParameter CreateParameter(ParameterDirection direction, string paramName, MySqlDbType dbtype, int size, object value)
 {
     MySqlParameter param = new MySqlParameter(paramName, dbtype, size);
     param.Value = value;
     param.Direction = direction;
     return param;
 }
    internal MySqlGeometry(MySqlDbType type, Double xValue, Double yValue, int srid)
    {
      this._type = type;
      this._xValue = xValue;
      this._yValue = yValue;      
      this._isNull = false;
      this._srid = srid;
      this._valBinary = new byte[GEOMETRY_LENGTH];

      byte[] sridBinary = BitConverter.GetBytes(srid);

      for (int i = 0; i < sridBinary.Length; i++)
        _valBinary[i] = sridBinary[i];

      long xVal = BitConverter.DoubleToInt64Bits(xValue);
      long yVal = BitConverter.DoubleToInt64Bits(yValue);

      _valBinary[4] = 1;
      _valBinary[5] = 1;
     
      for (int i = 0; i < 8; i++)
        {
          _valBinary[i + 9] = (byte)(xVal & 0xff);
          xVal >>= 8;
        }

      for (int i = 0; i < 8; i++)
      {
        _valBinary[i + 17] = (byte)(yVal & 0xff);
        yVal >>= 8;
      }
    }
Esempio n. 3
0
		public string DbTypeToString(MySqlDbType type, int? length)
		{
			string ret;
			if (TypesAsStrings.TryGetValue(type, out ret))
				return ret;
			throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
		}
Esempio n. 4
0
 public MySqlBinary(MySqlDbType type, bool isNull)
 {
     this.type = type;
     this.isNull = isNull;
     this.mValue = null;
     this.IsGuid = false;
 }
Esempio n. 5
0
 public string DbTypeToString(MySqlDbType type, int? length)
 {
     string ret;
     if (TypesAsStrings.TryGetValue(type, out ret))
         return ret + (length != null ? "({0})".SFormat((int)length) : "");
     throw new NotImplementedException(Enum.GetName(typeof(MySqlDbType), type));
 }
Esempio n. 6
0
 public MySqlBinary(MySqlDbType type, byte[] val)
 {
     this.type = type;
     this.isNull = false;
     this.mValue = val;
     this.IsGuid = false;
 }
Esempio n. 7
0
 /// <summary>
 /// Binds a parameter to the command with the given value and type.
 /// </summary>
 /// <param name="parameterName">
 /// The parameter Name.
 /// </param>
 /// <param name="value">
 /// The value.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 public void AddParameter(string parameterName, object value, MySqlDbType type)
 {
     var parameter = new MySqlParameter();
     parameter.ParameterName = parameterName;
     parameter.Value = value;
     this.Command.Parameters.Add(parameter);
 }
Esempio n. 8
0
        ///<summary>
        ///</summary>
        ///<param name="paramName"></param>
        ///<param name="dbType"></param>
        ///<param name="size"></param>
        ///<param name="direction"></param>
        ///<param name="value"></param>
        ///<returns></returns>
        ///<exception cref="ArgumentOutOfRangeException"></exception>
        public static MySqlParameter MakeParam(string paramName, MySqlDbType dbType, int size, ParameterDirection direction, object value)
        {
            MySqlParameter sqlParameter = null;
            try
            {
                paramName = paramName ?? string.Empty;

                //modify reason:验证花时比较大
                //if (!MathUtils.IsMachVarName(paramName))
                //{
                //    throw new ArgumentOutOfRangeException("paramName", "参数名格式不正确");
                //}
                if (size > 0)
                {
                    sqlParameter = new MySqlParameter(FormatParamName(paramName), dbType, size);
                }
                else
                {
                    sqlParameter = new MySqlParameter(FormatParamName(paramName), dbType);
                }
                sqlParameter.Direction = direction;
                if (direction != ParameterDirection.Output || value != null)
                {
                    sqlParameter.Value = value;
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("{0}", ex);
            }
            return sqlParameter;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, the size, and the source column name.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size, string sourceColumn) : this(parameterName, dbType)
 {
   Size = size;
   Direction = ParameterDirection.Input;
   SourceColumn = sourceColumn;
   SourceVersion = DataRowVersion.Current;
 }
Esempio n. 10
0
		internal static void SetDSInfo(DataTable dsTable) {
			string[] strArray = new string[] { "INT", "YEAR", "MEDIUMINT" };
			MySqlDbType[] typeArray = new MySqlDbType[] { MySqlDbType.Int32, MySqlDbType.Year, MySqlDbType.Int24 };
			for (int i = 0; i < strArray.Length; i++) {
				DataRow row = dsTable.NewRow();
				row["TypeName"] = strArray[i];
				row["ProviderDbType"] = typeArray[i];
				row["ColumnSize"] = 0;
				row["CreateFormat"] = strArray[i];
				row["CreateParameters"] = null;
				row["DataType"] = "System.Int32";
				row["IsAutoincrementable"] = typeArray[i] != MySqlDbType.Year;
				row["IsBestMatch"] = true;
				row["IsCaseSensitive"] = false;
				row["IsFixedLength"] = true;
				row["IsFixedPrecisionScale"] = true;
				row["IsLong"] = false;
				row["IsNullable"] = true;
				row["IsSearchable"] = true;
				row["IsSearchableWithLike"] = false;
				row["IsUnsigned"] = false;
				row["MaximumScale"] = 0;
				row["MinimumScale"] = 0;
				row["IsConcurrencyType"] = DBNull.Value;
				row["IsLiteralsSupported"] = false;
				row["LiteralPrefix"] = null;
				row["LiteralSuffix"] = null;
				row["NativeDataType"] = null;
				dsTable.Rows.Add(row);
			}
		}
Esempio n. 11
0
 public MySqlParameter AddParameter(string ParameterName, MySqlDbType type, int size, object value, ParameterDirection direction)
 {
     MySqlParameter param = new MySqlParameter(ParameterName, type, size);
     param.Direction = direction;
     param.Value = value;
     Command.Parameters.Add(param);
     return param;
 }
 internal MySqlParameter(string name, MySqlDbType type, ParameterDirection dir, string col, DataRowVersion ver, object val)
   : this(name, type)
 {
   Direction = dir;
   SourceColumn = col;
   SourceVersion = ver;
   Value = val;
 }
Esempio n. 13
0
 private static MySqlParameter getParameter(string Name, MySqlDbType Type, object Value)
 {
     MySqlParameter param = new MySqlParameter();
     param.ParameterName = Name;
     param.MySqlDbType = Type;
     param.Value = Value;
     return param;
 }
Esempio n. 14
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and a value of the new MySqlParameter.
		/// </summary>
		/// <param name="parameterName">The name of the parameter to map. </param>
		/// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
		public MySqlParameter(string parameterName, object value)
		{
			ParameterName = parameterName;
			paramValue = value;
			if (value is Byte[])
				size = (value as Byte[]).Length;
			dbType = GetMySqlType();
			genericType = GetGenericType();
		}
Esempio n. 15
0
 public static void addSqlParam(string name, ParameterDirection direction, int size, MySqlDbType type)
 {
     MySqlParameter sqlParam = new MySqlParameter();
     sqlParam.ParameterName = name;
     sqlParam.Direction = direction;
     sqlParam.Size = size;
     sqlParam.MySqlDbType = type;
     sqlParms.Add(sqlParam);
 }
Esempio n. 16
0
 internal MySqlGeometry(MySqlDbType type, bool isNull)
 {
   this._type = type;
   isNull = true;
   _xValue = 0;
   _yValue = 0;
   _srid = 0;
   _valBinary = null;
   this._isNull = isNull;
 }
Esempio n. 17
0
		internal MySqlDateTime(MySqlDbType type, int year, int month, int day, int hour, int minute, int second) {
			this.isNull = false;
			this.type = type;
			this.year = year;
			this.month = month;
			this.day = day;
			this.hour = hour;
			this.minute = minute;
			this.second = second;
			this.millisecond = 0;
		}
Esempio n. 18
0
		public MySqlDateTime(MySqlDateTime mdt) {
			this.year = mdt.Year;
			this.month = mdt.Month;
			this.day = mdt.Day;
			this.hour = mdt.Hour;
			this.minute = mdt.Minute;
			this.second = mdt.Second;
			this.millisecond = 0;
			this.type = MySqlDbType.DateTime;
			this.isNull = false;
		}
Esempio n. 19
0
 /// <summary>
 /// 增加SQL命令参数
 /// </summary>
 /// <param name="paraName">参数名</param>
 /// <param name="paraValue">参数值</param>
 /// <param name="paraDbType">数据类型</param>
 /// <param name="paraSize">参数长度</param>
 /// <param name="paraDirection">参数类型(in, out, inout)</param>
 /// <returns></returns>
 public static MySqlParameter AddParameter(string paraName, object paraValue, MySqlDbType paraDbType, int paraSize, ParameterDirection paraDirection)
 {
     MySqlParameter par = new MySqlParameter();
     par.ParameterName = paraName;
     par.Value = paraValue;
     par.Direction = paraDirection;
     par.MySqlDbType = paraDbType;
     if (paraSize > 0)
         par.Size = paraSize;
     return par;
 }
Esempio n. 20
0
		internal MySqlDateTime(MySqlDbType type, DateTime val)
			: this(type, 0, 0, 0, 0, 0, 0) {
			this.isNull = false;
			this.year = val.Year;
			this.month = val.Month;
			this.day = val.Day;
			this.hour = val.Hour;
			this.minute = val.Minute;
			this.second = val.Second;
			this.millisecond = val.Millisecond;
		}
Esempio n. 21
0
 /// <summary>
 /// Constructs a new <b>MySqlDateTime</b> object by copying the current value of the given object.
 /// </summary>
 /// <param name="mdt">The <b>MySqlDateTime</b> object to copy.</param>
 public MySqlDateTime(MySqlDateTime mdt)
 {
   year = mdt.Year;
   month = mdt.Month;
   day = mdt.Day;
   hour = mdt.Hour;
   minute = mdt.Minute;
   second = mdt.Second;
   millisecond = 0;
   type = MySqlDbType.DateTime;
   isNull = false;
 }
Esempio n. 22
0
 /// <summary>
 /// Adds a parameter to the parameteres collection of the command object
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Type"></param>
 /// <param name="Size"></param>
 /// <param name="Value"></param>
 public void AddParameter(string Name, MySqlDbType Type, int Size, object Value)
 {
     try
     {
         Command.Parameters.Add(Name, Type, Size).Value = Value;
         Command.Parameters[Name].Direction = ParameterDirection.Input;
     }
     catch(MySqlException e)
     {
         throw new System.Exception(e.Message, e.InnerException);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the type of the parameter, the size of the parameter, a <see cref="ParameterDirection"/>, the precision of the parameter, the scale of the parameter, the source column, a <see cref="DataRowVersion"/> to use, and the value of the parameter.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 /// <param name="direction">One of the <see cref="ParameterDirection"/> values. </param>
 /// <param name="isNullable">true if the value of the field can be null, otherwise false. </param>
 /// <param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="MySqlParameter.Value"/> is resolved.</param>
 /// <param name="scale">The total number of decimal places to which <see cref="MySqlParameter.Value"/> is resolved. </param>
 /// <param name="sourceColumn">The name of the source column. </param>
 /// <param name="sourceVersion">One of the <see cref="DataRowVersion"/> values. </param>
 /// <param name="value">An <see cref="Object"/> that is the value of the <see cref="MySqlParameter"/>. </param>
 /// <exception cref="ArgumentException"/>
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size, ParameterDirection direction,
                       bool isNullable, byte precision, byte scale, string sourceColumn,
                       DataRowVersion sourceVersion,
                       object value)
   : this(parameterName, dbType, size, sourceColumn)
 {
   Direction = direction;
   SourceVersion = sourceVersion;
   IsNullable = isNullable;
   Precision = precision;
   Scale = scale;
   Value = value;
 }
Esempio n. 24
0
 private static DbParameter CreateParam(string ParamName, MySqlDbType DbType, int Size, ParameterDirection Direction, object Value)
 {
     DbParameter parameter;
     if (Size > 0)
     {
         parameter = new MySqlParameter(ParamName, DbType, Size);
     }
     else
     {
         parameter = new MySqlParameter(ParamName, DbType);
     }
     parameter.Direction = Direction;
     if ((Direction != ParameterDirection.Output) || (Value != null))
     {
         parameter.Value = Value;
     }
     return parameter;
 }
Esempio n. 25
0
        public MySqlGeometry(MySqlDbType type, byte[] val)
        {
            if (val == null)
            throw new ArgumentNullException("val");

              byte[] buffValue = new byte[val.Length];

              for (int i = 0; i < val.Length; i++)
               buffValue[i] = val[i];

              var xIndex = val.Length == GEOMETRY_LENGTH ? 9 : 5;
              var yIndex = val.Length == GEOMETRY_LENGTH ? 17 : 13;

              _valBinary = buffValue;
              _xValue = BitConverter.ToDouble(val, xIndex);
              _yValue = BitConverter.ToDouble(val, yIndex);
              this._srid = val.Length == GEOMETRY_LENGTH ? BitConverter.ToInt32(val, 0) : 0;
              this._isNull = false;
              this._type = type;
        }
 /// <summary>
 /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, the column length, and the source column name.
 /// </summary>
 /// <param name="parameterName">The name of the parameter.</param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the column.</param>
 /// <param name="sourceColumn">The name of the source column.</param>
 /// <returns>The newly added <see cref="MySqlParameter"/> object.</returns>
 public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size, string sourceColumn)
 {
     return(Add(new MySqlParameter(parameterName, dbType, size, sourceColumn)));
 }
Esempio n. 27
0
 private void SetMySqlDbType(MySqlDbType mysql_dbtype)
 {
     mySqlDbType = mysql_dbtype;
     ValueObject = MySqlField.GetIMySqlValue(mySqlDbType);
     SetDbTypeFromMySqlDbType();
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name, the <see cref="MySqlDbType"/>, and the size.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the parameter. </param>
 public MySqlParameter(string parameterName, MySqlDbType dbType, int size) : this(parameterName, dbType)
 {
     Size = size;
 }
 private static Action <MySqlParameter> AssertParameter(string name, ParameterDirection direction, MySqlDbType mySqlDbType)
 {
     return(x =>
     {
         Assert.Equal(name, x.ParameterName);
         Assert.Equal(direction, x.Direction);
         Assert.Equal(mySqlDbType, x.MySqlDbType);
     });
 }
 public static int GetDefaultColumnSize(MySqlDbType PropertyColumnType) => MySqlTypeConverter.Where(x => x.Item2 == PropertyColumnType).FirstOrDefault()?.Item4 ?? default;
Esempio n. 31
0
        public static ushort ConvertToColumnTypeAndFlags(MySqlDbType dbType, MySqlGuidFormat guidFormat)
        {
            var        isUnsigned = false;
            ColumnType columnType;

            switch (dbType)
            {
            case MySqlDbType.Bool:
            case MySqlDbType.Byte:
                columnType = ColumnType.Tiny;
                break;

            case MySqlDbType.UByte:
                columnType = ColumnType.Tiny;
                isUnsigned = true;
                break;

            case MySqlDbType.Int16:
                columnType = ColumnType.Short;
                break;

            case MySqlDbType.UInt16:
                columnType = ColumnType.Short;
                isUnsigned = true;
                break;

            case MySqlDbType.Int24:
                columnType = ColumnType.Int24;
                break;

            case MySqlDbType.UInt24:
                columnType = ColumnType.Int24;
                isUnsigned = true;
                break;

            case MySqlDbType.Int32:
                columnType = ColumnType.Long;
                break;

            case MySqlDbType.UInt32:
                columnType = ColumnType.Long;
                isUnsigned = true;
                break;

            case MySqlDbType.Int64:
                columnType = ColumnType.Longlong;
                break;

            case MySqlDbType.UInt64:
                columnType = ColumnType.Longlong;
                isUnsigned = true;
                break;

            case MySqlDbType.Bit:
                columnType = ColumnType.Bit;
                break;

            case MySqlDbType.Guid:
                if (guidFormat == MySqlGuidFormat.Char36 || guidFormat == MySqlGuidFormat.Char32)
                {
                    columnType = ColumnType.String;
                }
                else
                {
                    columnType = ColumnType.Blob;
                }
                break;

            case MySqlDbType.Enum:
            case MySqlDbType.Set:
                columnType = ColumnType.String;
                break;

            case MySqlDbType.Binary:
            case MySqlDbType.String:
                columnType = ColumnType.String;
                break;

            case MySqlDbType.VarBinary:
            case MySqlDbType.VarChar:
            case MySqlDbType.VarString:
                columnType = ColumnType.VarString;
                break;

            case MySqlDbType.TinyBlob:
            case MySqlDbType.TinyText:
                columnType = ColumnType.TinyBlob;
                break;

            case MySqlDbType.Blob:
            case MySqlDbType.Text:
                columnType = ColumnType.Blob;
                break;

            case MySqlDbType.MediumBlob:
            case MySqlDbType.MediumText:
                columnType = ColumnType.MediumBlob;
                break;

            case MySqlDbType.LongBlob:
            case MySqlDbType.LongText:
                columnType = ColumnType.LongBlob;
                break;

            case MySqlDbType.JSON:
                columnType = ColumnType.Json;                 // TODO: test
                break;

            case MySqlDbType.Date:
            case MySqlDbType.Newdate:
                columnType = ColumnType.Date;
                break;

            case MySqlDbType.DateTime:
                columnType = ColumnType.DateTime;
                break;

            case MySqlDbType.Timestamp:
                columnType = ColumnType.Timestamp;
                break;

            case MySqlDbType.Time:
                columnType = ColumnType.Time;
                break;

            case MySqlDbType.Year:
                columnType = ColumnType.Year;
                break;

            case MySqlDbType.Float:
                columnType = ColumnType.Float;
                break;

            case MySqlDbType.Double:
                columnType = ColumnType.Double;
                break;

            case MySqlDbType.Decimal:
                columnType = ColumnType.Decimal;
                break;

            case MySqlDbType.NewDecimal:
                columnType = ColumnType.NewDecimal;
                break;

            case MySqlDbType.Geometry:
                columnType = ColumnType.Geometry;
                break;

            case MySqlDbType.Null:
                columnType = ColumnType.Null;
                break;

            default:
                throw new NotImplementedException("ConvertToColumnTypeAndFlags for {0} is not implemented".FormatInvariant(dbType));
            }

            return((ushort)((byte)columnType | (isUnsigned ? 0x8000 : 0)));
        }
Esempio n. 32
0
        protected static string GetDataReaderMethod(MySqlDbType type)
        {
            switch (type)
            {
            case MySqlDbType.Bit: return("GetBoolean");

            case MySqlDbType.Byte: return("GetByte");

            case MySqlDbType.Int16: return("GetInt16");

            case MySqlDbType.Int24:
            case MySqlDbType.Int32: return("GetInt32");

            case MySqlDbType.Int64: return("GetInt64");

            case MySqlDbType.UByte: return("GetByte");

            case MySqlDbType.UInt16: return("GetInt16");

            case MySqlDbType.UInt24:
            case MySqlDbType.UInt32: return("GetInt32");

            case MySqlDbType.UInt64: return("GetInt64");

            case MySqlDbType.Double: return("GetDouble");

            case MySqlDbType.Float: return("GetFloat");

            case MySqlDbType.Decimal: return("GetDecimal");

            case MySqlDbType.Year: return("GetInt32");

            case MySqlDbType.Time: return("GetValue");

            case MySqlDbType.Date:
            case MySqlDbType.Timestamp:
            case MySqlDbType.Datetime: return("GetDateTime");

            case MySqlDbType.TinyBlob:
            case MySqlDbType.Blob:
            case MySqlDbType.MediumBlob:
            case MySqlDbType.LongBlob:

            case MySqlDbType.Binary:
            case MySqlDbType.VarBinary: return("GetBytes");

            case MySqlDbType.TinyText:
            case MySqlDbType.Text:
            case MySqlDbType.MediumText:
            case MySqlDbType.LongText:

            case MySqlDbType.String:
            case MySqlDbType.VarString:
            case MySqlDbType.VarChar: return("GetString");

            case MySqlDbType.Set:
            case MySqlDbType.Enum: return("GetString");

            default: return("GetValue");
            }
        }
 protected MySqlYearTypeMapping(RelationalTypeMappingParameters parameters, MySqlDbType mySqlDbType)
     : base(parameters, mySqlDbType)
 {
 }
 public MySqlParameter(string?name, MySqlDbType mySqlDbType, int size)
     : this(name, mySqlDbType, size, null)
 {
 }
 public MySqlBinary(MySqlDbType type, byte[] val)
 {
     this.type   = type;
     this.isNull = false;
     mValue      = val;
 }
 public MySqlParameter(string?name, MySqlDbType mySqlDbType)
     : this(name, mySqlDbType, 0)
 {
 }
Esempio n. 37
0
 public DbType(MySqlDbType type)
 {
     this.DatabaseServer    = DatabaseServer.MySql;
     this.MySqlServerDbType = type;
 }
Esempio n. 38
0
 public MySqlBinary(byte[] val, MySqlDbType type)
 {
     this.Value       = val;
     this.mySqlDbType = type;
 }
 public static Type ColumnTypeToPropertyType(MySqlDbType PropertyColumnType) => MySqlTypeConverter.Where(x => x.Item2 == PropertyColumnType).FirstOrDefault()?.Item3;
Esempio n. 40
0
 ///<summary>
 ///</summary>
 ///<param name="paramName"></param>
 ///<param name="dbType"></param>
 ///<param name="size"></param>
 ///<returns></returns>
 public static MySqlParameter MakeOutParam(string paramName, MySqlDbType dbType, int size)
 {
     return(MakeParam(paramName, dbType, size, ParameterDirection.Output, null));
 }
Esempio n. 41
0
 public MySqlUInt16(MySqlDbType type) : this()
 {
     this.mySqlDbType = type;
 }
Esempio n. 42
0
        ///<summary>
        ///</summary>
        ///<param name="paramName"></param>
        ///<param name="value"></param>
        ///<returns></returns>
        public static MySqlParameter MakeInParam(string paramName, object value)
        {
            MySqlDbType dbType = GetDbType(value);

            return(MakeParam(paramName, dbType, 0, ParameterDirection.Input, value));
        }
Esempio n. 43
0
 public DbType GetDbTypeForMySqlDbType(MySqlDbType mySqlDbType) => m_mySqlDbTypeToColumnTypeMetadata[mySqlDbType].DbTypeMapping.DbTypes[0];
Esempio n. 44
0
 ///<summary>
 ///</summary>
 ///<param name="paramName"></param>
 ///<param name="dbType"></param>
 ///<param name="size"></param>
 ///<param name="value"></param>
 ///<returns></returns>
 public static MySqlParameter MakeInParam(string paramName, MySqlDbType dbType, int size, object value)
 {
     return(MakeParam(paramName, dbType, size, ParameterDirection.Input, value));
 }
Esempio n. 45
0
 public ColumnTypeMetadata GetColumnTypeMetadata(MySqlDbType mySqlDbType) => m_mySqlDbTypeToColumnTypeMetadata[mySqlDbType];
Esempio n. 46
0
 public MySqlInt32(MySqlDbType type, int val)
     : this(type)
 {
     this.isNull = false;
     mValue      = val;
 }
Esempio n. 47
0
 public MySQLFieldDefinition(string field, MySqlDbType type) : this()
 {
     FieldName     = field;
     ParameterType = type;
 }
        public static void SetDSInfo(DataTable dsTable)
        {
            string[] types = new string[] { "BLOB", "TINYBLOB", "MEDIUMBLOB", "LONGBLOB", "BINARY", "VARBINARY" };
            MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.Blob,
                MySqlDbType.TinyBlob, MySqlDbType.MediumBlob, MySqlDbType.LongBlob, MySqlDbType.Binary, MySqlDbType.VarBinary };
            long[] sizes = new long[] { 65535L, 255L, 16777215L, 4294967295L, 255L, 65535L };
            string[] format = new string[] { null, null, null, null, "binary({0})", "varbinary({0})" };
            string[] parms = new string[] { null, null, null, null, "length", "length" };

            // we use name indexing because this method will only be called
            // when GetSchema is called for the DataSourceInformation
            // collection and then it wil be cached.
            for (int x = 0; x < types.Length; x++)
            {
                DataRow row = dsTable.NewRow();
                row["TypeName"] = types[x];
                row["ProviderDbType"] = dbtype[x];
                row["ColumnSize"] = sizes[x];
                row["CreateFormat"] = format[x];
                row["CreateParameters"] = parms[x];
                row["DataType"] = "System.Byte[]";
                row["IsAutoincrementable"] = false;
                row["IsBestMatch"] = true;
                row["IsCaseSensitive"] = false;
                row["IsFixedLength"] = x < 4 ? false : true;
                row["IsFixedPrecisionScale"] = false;
                row["IsLong"] = sizes[x] > 255;
                row["IsNullable"] = true;
                row["IsSearchable"] = false;
                row["IsSearchableWithLike"] = false;
                row["IsUnsigned"] = DBNull.Value;
                row["MaximumScale"] = DBNull.Value;
                row["MinimumScale"] = DBNull.Value;
                row["IsConcurrencyType"] = DBNull.Value;
                row["IsLiteralSupported"] = false;
                row["LiteralPrefix"] = "0x";
                row["LiteralSuffix"] = DBNull.Value;
                row["NativeDataType"] = DBNull.Value;
                dsTable.Rows.Add(row);
            }
        }
Esempio n. 49
0
 internal MySqlDateTime(MySqlDbType type, bool isNull)
     : this(type, 0, 0, 0, 0, 0, 0, 0)
 {
     this.isNull = isNull;
 }
Esempio n. 50
0
 internal MySqlDateTime(MySqlDbType type, bool isNull)
   : this(type, 0, 0, 0, 0, 0, 0, 0)
 {
   this.isNull = isNull;
 }
Esempio n. 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MySqlParameter"/> class with the parameter name and the data type.
 /// </summary>
 /// <param name="parameterName">The name of the parameter to map. </param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 public MySqlParameter(string parameterName, MySqlDbType dbType) : this(parameterName, null)
 {
     MySqlDbType = dbType;
 }
Esempio n. 52
0
    internal static void SetDSInfo(DataTable dsTable)
    {
      var types = new string[] { "DATE", "DATETIME", "TIMESTAMP" };
      var dbtype = new MySqlDbType[] { MySqlDbType.Date, 
        MySqlDbType.DateTime, MySqlDbType.Timestamp };

      // we use name indexing because this method will only be called
      // when GetSchema is called for the DataSourceInformation 
      // collection and then it wil be cached.
      for (var x = 0; x < types.Length; x++)
      {
        var row = dsTable.NewRow();
        row["TypeName"] = types[x];
        row["ProviderDbType"] = dbtype[x];
        row["ColumnSize"] = 0;
        row["CreateFormat"] = types[x];
        row["CreateParameters"] = null;
        row["DataType"] = "System.DateTime";
        row["IsAutoincrementable"] = false;
        row["IsBestMatch"] = true;
        row["IsCaseSensitive"] = false;
        row["IsFixedLength"] = true;
        row["IsFixedPrecisionScale"] = true;
        row["IsLong"] = false;
        row["IsNullable"] = true;
        row["IsSearchable"] = true;
        row["IsSearchableWithLike"] = false;
        row["IsUnsigned"] = false;
        row["MaximumScale"] = 0;
        row["MinimumScale"] = 0;
        row["IsConcurrencyType"] = DBNull.Value;
        row["IsLiteralSupported"] = false;
        row["LiteralPrefix"] = null;
        row["LiteralSuffix"] = null;
        row["NativeDataType"] = null;
        dsTable.Rows.Add(row);
      }
    }
Esempio n. 53
0
 public MySqlInt32(MySqlDbType type, bool isNull)
     : this(type)
 {
     this.isNull = isNull;
 }
 /// <summary>
 /// Adds a <see cref="MySqlParameter"/> to the <see cref="MySqlParameterCollection"/> with the parameter name, the data type, and the column length.
 /// </summary>
 /// <param name="parameterName">The name of the parameter.</param>
 /// <param name="dbType">One of the <see cref="MySqlDbType"/> values. </param>
 /// <param name="size">The length of the column.</param>
 /// <returns>The newly added <see cref="MySqlParameter"/> object.</returns>
 public MySqlParameter Add(string parameterName, MySqlDbType dbType, int size)
 {
     return(Add(new MySqlParameter(parameterName, dbType, size)));
 }
 public MySqlBinary(MySqlDbType type, bool isNull)
 {
     this.type = type;
     this.isNull = isNull;
     mValue = null;
 }
Esempio n. 56
0
 private MySqlInt32(MySqlDbType type)
 {
     is24Bit = type == MySqlDbType.Int24 ? true : false;
     isNull  = true;
     mValue  = 0;
 }
Esempio n. 57
0
 internal MySqlDateTime(MySqlDbType type, DateTime val)
   : this(type, 0, 0, 0, 0, 0, 0, 0)
 {
   isNull = false;
   year = val.Year;
   month = val.Month;
   day = val.Day;
   hour = val.Hour;
   minute = val.Minute;
   second = val.Second;
   millisecond = val.Millisecond;
 }
Esempio n. 58
0
 private MySqlParameter SetParameter(string param, MySqlDbType type)
 {
     return(new MySqlParameter(param, type));
 }
Esempio n. 59
0
        protected static string GetCSType(MySqlDbType type, string enumType)
        {
            switch (type)
            {
            case MySqlDbType.Bit: return("bool?");

            case MySqlDbType.Byte: return("byte?");

            case MySqlDbType.Int16: return("short?");

            case MySqlDbType.Int24:
            case MySqlDbType.Int32: return("int?");

            case MySqlDbType.Int64: return("long?");

            case MySqlDbType.UByte: return("byte?");

            case MySqlDbType.UInt16: return("ushort?");

            case MySqlDbType.UInt24:
            case MySqlDbType.UInt32: return("uint?");

            case MySqlDbType.UInt64: return("ulong?");

            case MySqlDbType.Double: return("double?");

            case MySqlDbType.Float: return("float?");

            case MySqlDbType.Decimal: return("decimal?");

            case MySqlDbType.Year: return("int?");

            case MySqlDbType.Time: return("TimeSpan?");

            case MySqlDbType.Date:
            case MySqlDbType.Timestamp:
            case MySqlDbType.Datetime: return("DateTime?");

            case MySqlDbType.TinyBlob:
            case MySqlDbType.Blob:
            case MySqlDbType.MediumBlob:
            case MySqlDbType.LongBlob:

            case MySqlDbType.Binary:
            case MySqlDbType.VarBinary: return("byte[]");

            case MySqlDbType.TinyText:
            case MySqlDbType.Text:
            case MySqlDbType.MediumText:
            case MySqlDbType.LongText:

            case MySqlDbType.String:
            case MySqlDbType.VarString:
            case MySqlDbType.VarChar: return("string");

            case MySqlDbType.Set: return(enumType + "?");

            case MySqlDbType.Enum: return(enumType + "?");

            default: return("object");
            }
        }
 public static string ColumnTypeToColumnName(MySqlDbType PropertyColumnType) => MySqlTypeConverter.Where(x => x.Item2 == PropertyColumnType).FirstOrDefault()?.Item1;