From: <aye...@us...> - 2009-05-13 05:29:28
|
Revision: 4284 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4284&view=rev Author: ayenderahien Date: 2009-05-13 05:29:16 +0000 (Wed, 13 May 2009) Log Message: ----------- only do the log preparation if either logger wants it Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-12 15:29:32 UTC (rev 4283) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-13 05:29:16 UTC (rev 4284) @@ -32,19 +32,23 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); + currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + } + else if (log.IsDebugEnabled) + { + log.Debug("Adding to batch:" + lineWithParameters); + } + currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); + } + if (currentBatch.CountOfCommands >= batchSize) { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else if (log.IsDebugEnabled) - { - log.Debug("Adding to batch:" + lineWithParameters); - } - currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); - if (currentBatch.CountOfCommands >= batchSize) - { DoExecuteBatch(batchUpdate); } } @@ -54,12 +58,15 @@ log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); - else if (log.IsDebugEnabled) - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - int rowsAffected = currentBatch.ExecuteNonQuery(); + if (log.IsDebugEnabled || Factory.Settings.SqlStatementLogger.IsDebugEnabled) + { + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) + Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); + else if (log.IsDebugEnabled) + log.Debug(currentBatchCommandsLog.ToString()); + currentBatchCommandsLog = new StringBuilder(); + } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |