public override void AddToBatch(IExpectation expectation)
        {
            totalExpectedRowsAffected += expectation.ExpectedRowCount;
            IDbCommand batchUpdate = CurrentCommand;

            Prepare(batchUpdate);
            Driver.AdjustCommand(batchUpdate);
            string lineWithParameters = null;
            var    sqlStatementLogger = Factory.Settings.SqlStatementLogger;

            if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled)
            {
                lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
                var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
                lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
                currentBatchCommandsLog.Append("command ")
                .Append(currentBatch.CountOfCommands)
                .Append(":")
                .AppendLine(lineWithParameters);
            }
            if (Log.IsDebugEnabled)
            {
                Log.Debug("Adding to batch:" + lineWithParameters);
            }
            currentBatch.Append(batchUpdate);

            if (currentBatch.CountOfCommands >= batchSize)
            {
                DoExecuteBatch(batchUpdate);
            }
        }
예제 #2
0
        public override void AddToBatch(IExpectation expectation)
        {
            // MySql batcher cannot be initiated if a data reader is still open: check them.
            if (CountOfStatementsInCurrentBatch == 0)
            {
                CheckReaders();
            }

            totalExpectedRowsAffected += expectation.ExpectedRowCount;
            var batchUpdate = CurrentCommand;

            Prepare(batchUpdate);
            Driver.AdjustCommand(batchUpdate);
            string lineWithParameters = null;
            var    sqlStatementLogger = Factory.Settings.SqlStatementLogger;

            if (sqlStatementLogger.IsDebugEnabled || Log.IsDebugEnabled())
            {
                lineWithParameters = sqlStatementLogger.GetCommandLineWithParameters(batchUpdate);
                var formatStyle = sqlStatementLogger.DetermineActualStyle(FormatStyle.Basic);
                lineWithParameters = formatStyle.Formatter.Format(lineWithParameters);
                currentBatchCommandsLog.Append("command ")
                .Append(currentBatch.CountOfCommands)
                .Append(":")
                .AppendLine(lineWithParameters);
            }
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Adding to batch:{0}", lineWithParameters);
            }
            currentBatch.Append(batchUpdate);

            if (currentBatch.CountOfCommands >= batchSize)
            {
                DoExecuteBatch(batchUpdate);
            }
        }