protected override void DoExecuteBatch(DbCommand ps) { Log.DebugFormat("Executing batch"); CheckReaders(); Prepare(_currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } int rowsAffected; try { rowsAffected = _currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected); _currentBatch.Dispose(); _totalExpectedRowsAffected = 0; _currentBatch = CreateConfiguredBatch(); }
public ProfiledSqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { _batchSize = Factory.Settings.AdoBatchSize; _defaultTimeout = PropertiesHelper.GetInt32(global::NHibernate.Cfg.Environment.CommandTimeout, global::NHibernate.Cfg.Environment.Properties, -1); _currentBatch = CreateConfiguredBatch(); _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); }
private void ClearCurrentBatch() { _currentBatch.Dispose(); _totalExpectedRowsAffected = 0; _currentBatch = CreateConfiguredBatch(); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } }
public SqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); SetCommandTimeout(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception //at that point. currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); }
public SqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); SetCommandTimeout(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception //at that point. currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); }
public ProfiledSqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { batchSize = Factory.Settings.AdoBatchSize; defaultTimeout = PropertiesHelper.GetInt32(NHibernate.Cfg.Environment.CommandTimeout, NHibernate.Cfg.Environment.Properties, -1); currentBatch = CreateConfiguredBatch(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception //at that point. currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); }
public SqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { _batchSize = Factory.Settings.AdoBatchSize; _defaultTimeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1); _currentBatch = CreateConfiguredBatch(); //we always create this, because we need to deal with a scenario in which //the user change the logging configuration at runtime. Trying to put this //behind an if(log.IsDebugEnabled) will cause a null reference exception //at that point. _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); }
protected override void DoExecuteBatch(IDbCommand ps) { log.Debug("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); logSql.Debug(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); currentBatch.Dispose(); totalExpectedRowsAffected = 0; currentBatch = new SqlClientSqlCommandSet(); }
protected override void DoExecuteBatch(IDbCommand ps) { log.DebugFormat("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); currentBatch.Dispose(); totalExpectedRowsAffected = 0; currentBatch = new SqlClientSqlCommandSet(); }
private SqlClientSqlCommandSet CreateConfiguredBatch() { var result = new SqlClientSqlCommandSet(); if (_defaultTimeout > 0) { try { result.CommandTimeout = _defaultTimeout; } catch (Exception e) { if (Log.IsWarnEnabled()) { Log.Warn(e, e.ToString()); } } } return(result); }
private SqlClientSqlCommandSet CreateConfiguredBatch() { var result = new SqlClientSqlCommandSet(); if (this.defaultTimeout > 0) { try { result.CommandTimeout = this.defaultTimeout; } catch (Exception e) { if (Log.IsWarnEnabled) { Log.Warn(e.ToString()); } } } return result; }
protected override void DoExecuteBatch(IDbCommand ps) { Log.DebugFormat("Executing batch"); this.CheckReaders(); this.Prepare(this.currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(this.currentBatchCommandsLog.ToString()); this.currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } if (this.profiler != null) { this.profiler.ExecuteStart(this.currentBatch.BatchCommand, ExecuteType.NonQuery); } int rowsAffected; try { rowsAffected = this.currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } if (this.profiler != null) { this.profiler.ExecuteFinish(this.currentBatch.BatchCommand, ExecuteType.NonQuery, null); } Expectations.VerifyOutcomeBatched(this.totalExpectedRowsAffected, rowsAffected); this.currentBatch.Dispose(); this.totalExpectedRowsAffected = 0; this.currentBatch = this.CreateConfiguredBatch(); }
protected override void DoExecuteBatch(IDbCommand ps) { log.DebugFormat("Executing batch"); CheckReaders(); Prepare(currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); currentBatch.Dispose(); totalExpectedRowsAffected = 0; currentBatch = new SqlClientSqlCommandSet(); }
protected override void DoExecuteBatch(IDbCommand ps) { CheckReaders(); Prepare(_currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } int rowsAffected; try { rowsAffected = _currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected); _currentBatch.Dispose(); _totalExpectedRowsAffected = 0; _currentBatch = CreateConfiguredBatch(); }
private SqlClientSqlCommandSet CreateConfiguredBatch() { var result = new SqlClientSqlCommandSet(); if (_defaultTimeout > 0) { try { result.CommandTimeout = _defaultTimeout; } catch {} } return result; }
public SqlClientBatchingBatcher(ConnectionManager connectionManager, IInterceptor interceptor) : base(connectionManager, interceptor) { batchSize = Factory.Settings.AdoBatchSize; currentBatch = new SqlClientSqlCommandSet(); }