internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings) { if (!binary && (paramValue == null || paramValue == DBNull.Value)) { packet.WriteStringNoNull("NULL"); } else { if (ValueObject.MySqlDbType == MySqlDbType.Guid) { MySqlGuid g = (MySqlGuid)ValueObject; g.OldGuids = settings.OldGuids; ValueObject = g; } #if !CF if (ValueObject.MySqlDbType == MySqlDbType.Geometry) { MySqlGeometry v = (MySqlGeometry)ValueObject; if (v.IsNull && Value != null) { MySqlGeometry.TryParse(Value.ToString(), out v); } ValueObject = v; } #endif ValueObject.WriteValue(packet, binary, paramValue, Size); } }
public IMySqlValue GetValueObject() { IMySqlValue v = GetIMySqlValue(Type); if (v is MySqlByte && ColumnLength == 1 && driver.Settings.TreatTinyAsBoolean) { MySqlByte b = (MySqlByte)v; b.TreatAsBoolean = true; v = b; } else if (v is MySqlGuid) { MySqlGuid g = (MySqlGuid)v; g.OldGuids = driver.Settings.OldGuids; v = g; } return v; }
internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings) { if (!binary && (paramValue == null || paramValue == DBNull.Value)) { packet.WriteStringNoNull("NULL"); } else { if (ValueObject.MySqlDbType == MySqlDbType.Guid) { MySqlGuid g = (MySqlGuid)ValueObject; g.OldGuids = settings.OldGuids; valueObject = g; } ValueObject.WriteValue(packet, binary, paramValue, size); } }
public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { if (i >= this.FieldCount) { this.Throw(new IndexOutOfRangeException()); } IMySqlValue fieldValue = this.GetFieldValue(i, false); if (!(fieldValue is MySqlBinary) && !(fieldValue is MySqlGuid)) { this.Throw(new MySqlException("GetBytes can only be called on binary or guid columns")); } byte[] src = null; if (fieldValue is MySqlBinary) { MySqlBinary binary = (MySqlBinary)fieldValue; src = binary.Value; } else { MySqlGuid guid = (MySqlGuid)fieldValue; src = guid.Bytes; } if (buffer == null) { return((long)src.Length); } if ((bufferoffset >= buffer.Length) || (bufferoffset < 0)) { this.Throw(new IndexOutOfRangeException("Buffer index must be a valid index in buffer")); } if (buffer.Length < (bufferoffset + length)) { this.Throw(new ArgumentException("Buffer is not large enough to hold the requested data")); } if ((fieldOffset < 0L) || ((fieldOffset >= src.Length) && (src.Length > 0L))) { this.Throw(new IndexOutOfRangeException("Data index must be a valid index in the field")); } if (src.Length < (fieldOffset + length)) { length = src.Length - ((int)fieldOffset); } Buffer.BlockCopy(src, (int)fieldOffset, buffer, bufferoffset, length); return((long)length); }
public IMySqlValue GetValueObject() { IMySqlValue mySqlValue = MySqlField.GetIMySqlValue(this.Type); if (mySqlValue is MySqlByte && this.ColumnLength == 1 && this.driver.Settings.TreatTinyAsBoolean) { MySqlByte mySqlByte = (MySqlByte)mySqlValue; mySqlByte.TreatAsBoolean = true; mySqlValue = mySqlByte; } else if (mySqlValue is MySqlGuid) { MySqlGuid mySqlGuid = (MySqlGuid)mySqlValue; mySqlGuid.OldGuids = this.driver.Settings.OldGuids; mySqlValue = mySqlGuid; } return(mySqlValue); }
internal void Serialize(MySqlPacket packet, bool binary, MySqlConnectionStringBuilder settings) { if (!binary && (this.paramValue == null || this.paramValue == DBNull.Value)) { packet.WriteStringNoNull("NULL"); return; } if (this.ValueObject.MySqlDbType == MySqlDbType.Guid) { MySqlGuid mySqlGuid = (MySqlGuid)this.ValueObject; mySqlGuid.OldGuids = settings.OldGuids; this.ValueObject = mySqlGuid; } if (this.ValueObject.MySqlDbType == MySqlDbType.Geometry) { MySqlGeometry mySqlGeometry = (MySqlGeometry)this.ValueObject; this.ValueObject = mySqlGeometry; } this.ValueObject.WriteValue(packet, binary, this.paramValue, this.Size); }