private bool SerializeParameter(MySqlParameterCollection parameters, MySqlStream stream, string parmName) { MySqlParameter parameterFlexible = parameters.GetParameterFlexible(parmName, false); if (parameterFlexible == null) { if (!parmName.StartsWith("@") || !this.ShouldIgnoreMissingParameter(parmName)) { throw new MySqlException(string.Format(Resources.ParameterMustBeDefined, parmName)); } return(false); } parameterFlexible.Serialize(stream, false); return(true); }
protected virtual void BindParameters() { MySqlParameterCollection parameters = this.command.Parameters; int num = 0; do { this.InternalBindParameters(this.ResolvedCommandText, parameters, null); if (this.command.Batch != null) { while (num < this.command.Batch.Count) { MySqlCommand command = this.command.Batch[num++]; MySqlStream stream = (MySqlStream)this.buffers[this.buffers.Count - 1]; long num2 = command.EstimatedSize(); if ((stream.InternalBuffer.Length + num2) > this.Connection.driver.MaxPacketSize) { parameters = command.Parameters; break; } this.buffers.RemoveAt(this.buffers.Count - 1); long length = stream.InternalBuffer.Length; string batchableCommandText = command.BatchableCommandText; if (batchableCommandText.StartsWith("(")) { stream.WriteStringNoNull(", "); } else { stream.WriteStringNoNull("; "); } this.InternalBindParameters(batchableCommandText, command.Parameters, stream); if (stream.InternalBuffer.Length > this.Connection.driver.MaxPacketSize) { stream.InternalBuffer.SetLength(length); parameters = command.Parameters; break; } } } else { return; } }while (num != this.command.Batch.Count); }