protected virtual void BindParameters() { MySqlParameterCollection parameters = command.Parameters; int index = 0; while (true) { InternalBindParameters(ResolvedCommandText, parameters, null); // if we are not batching, then we are done. This is only really relevant the // first time through if (command.Batch == null) { return; } while (index < command.Batch.Count) { MySqlCommand batchedCmd = command.Batch[index++]; MySqlPacket packet = (MySqlPacket)buffers[buffers.Count - 1]; // now we make a guess if this statement will fit in our current stream long estimatedCmdSize = batchedCmd.EstimatedSize(); if (((packet.Length - 4) + estimatedCmdSize) > Connection.driver.MaxPacketSize) { // it won't, so we setup to start a new run from here parameters = batchedCmd.Parameters; break; } // looks like we might have room for it so we remember the current end of the stream buffers.RemoveAt(buffers.Count - 1); //long originalLength = packet.Length - 4; // and attempt to stream the next command string text = batchedCmd.BatchableCommandText; if (text.StartsWith("(")) { packet.WriteStringNoNull(", "); } else { packet.WriteStringNoNull("; "); } InternalBindParameters(text, batchedCmd.Parameters, packet); if ((packet.Length - 4) > Connection.driver.MaxPacketSize) { //TODO //stream.InternalBuffer.SetLength(originalLength); parameters = batchedCmd.Parameters; break; } } if (index == command.Batch.Count) { return; } } }
protected virtual void BindParameters() { MySqlParameterCollection parameters = this.command.Parameters; int i = 0; while (true) { this.InternalBindParameters(this.ResolvedCommandText, parameters, null); if (this.command.Batch == null) { break; } while (i < this.command.Batch.Count) { MySqlCommand mySqlCommand = this.command.Batch[i++]; MySqlPacket mySqlPacket = this.buffers[this.buffers.Count - 1]; long num = mySqlCommand.EstimatedSize(); if ((long)(mySqlPacket.Length - 4) + num > this.Connection.driver.MaxPacketSize) { parameters = mySqlCommand.Parameters; break; } this.buffers.RemoveAt(this.buffers.Count - 1); string resolvedCommandText = this.ResolvedCommandText; if (resolvedCommandText.StartsWith("(", StringComparison.Ordinal)) { mySqlPacket.WriteStringNoNull(", "); } else { mySqlPacket.WriteStringNoNull("; "); } this.InternalBindParameters(resolvedCommandText, mySqlCommand.Parameters, mySqlPacket); if ((long)(mySqlPacket.Length - 4) > this.Connection.driver.MaxPacketSize) { parameters = mySqlCommand.Parameters; break; } } if (i == this.command.Batch.Count) { return; } } }