protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); try { Log.Debug("Executing batch"); await(CheckReadersAsync(cancellationToken)).ConfigureAwait(false); await(PrepareAsync(_currentBatch.BatchCommand, cancellationToken)).ConfigureAwait(false); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); } int rowsAffected; try { rowsAffected = _currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected, ps); } finally { ClearCurrentBatch(); } }
protected override void DoExecuteBatch(IDbCommand ps) { Log.DebugFormat("Executing batch"); CheckReaders(); 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(); }
protected override void DoExecuteBatch(DbCommand ps) { try { Log.Debug("Executing batch"); CheckReaders(); Prepare(_currentBatch.BatchCommand); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); } int rowsAffected; try { rowsAffected = _currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected, ps); } finally { ClearCurrentBatch(); } }
protected override void DoExecuteBatch(IDbCommand ps) { if (currentBatch != null) { int arraySize = 0; countOfCommands = 0; log.Info("Executing batch"); CheckReaders(); Prepare(currentBatch); foreach (IDataParameter currentParameter in currentBatch.Parameters) { List <object> parameterValueArray = parameterValueListHashTable[currentParameter.ParameterName]; currentParameter.Value = parameterValueArray.ToArray(); arraySize = parameterValueArray.Count; } // setting the ArrayBindCount on the OracleCommand // this value is not a part of the ADO.NET API. // It's and ODP implementation, so it is being set by reflection SetObjectParam(currentBatch, "ArrayBindCount", arraySize); int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); totalExpectedRowsAffected = 0; currentBatch = null; parameterValueListHashTable = null; } }
protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (_currentBatch != null) { int arraySize = 0; _countOfCommands = 0; Log.Info("Executing batch"); await(CheckReadersAsync(cancellationToken)).ConfigureAwait(false); await(PrepareAsync(_currentBatch, cancellationToken)).ConfigureAwait(false); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } foreach (DbParameter currentParameter in _currentBatch.Parameters) { List <object> parameterValueArray = _parameterValueListHashTable[currentParameter.ParameterName]; currentParameter.Value = parameterValueArray.ToArray(); arraySize = parameterValueArray.Count; } // setting the ArrayBindCount on the OracleCommand // this value is not a part of the ADO.NET API. // It's and ODP implementation, so it is being set by reflection SetArrayBindCount(arraySize); try { int rowsAffected; try { rowsAffected = await(_currentBatch.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected); } finally { // Cleaning up even if batched outcome is invalid _totalExpectedRowsAffected = 0; _currentBatch = null; _parameterValueListHashTable = null; } } }
protected override async Task DoExecuteBatchAsync(DbCommand ps, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); Log.Info("Executing batch"); await(CheckReadersAsync(cancellationToken)).ConfigureAwait(false); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(_currentBatchCommandsLog.ToString()); _currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } try { int rowCount = 0; if (_countOfCommands > 0) { _currentBatch.Parameters.Clear(); foreach (var command in _currentBatchCommands) { // Batching with HANA works by simply defining multiple times each command parameter. // (Undocumented feature explained by a developer of the provider.) foreach (DbParameter parameter in command.Parameters) { _currentBatch.Parameters.Add(parameter); } } _currentBatch.Prepare(); try { rowCount = await(_currentBatch.ExecuteNonQueryAsync(cancellationToken)).ConfigureAwait(false); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowCount, ps); } finally { // Cleaning up even if batched outcome is invalid _totalExpectedRowsAffected = 0; _countOfCommands = 0; CloseBatchCommands(); } }
protected override void DoExecuteBatch(IDbCommand ps) { if (currentBatch != null) { int arraySize = 0; countOfCommands = 0; log.Info("Executing batch"); CheckReaders(); Prepare(currentBatch); if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:"); } foreach (IDataParameter currentParameter in currentBatch.Parameters) { List <object> parameterValueArray = parameterValueListHashTable[currentParameter.ParameterName]; currentParameter.Value = parameterValueArray.ToArray(); arraySize = parameterValueArray.Count; } // setting the ArrayBindCount on the OracleCommand // this value is not a part of the ADO.NET API. // It's and ODP implementation, so it is being set by reflection SetObjectParam(currentBatch, "ArrayBindCount", arraySize); int rowsAffected; try { rowsAffected = currentBatch.ExecuteNonQuery(); } catch (DbException e) { throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command."); } Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); totalExpectedRowsAffected = 0; currentBatch = null; parameterValueListHashTable = null; } }
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) { if (_currentBatch == null) { return; } _commandCount = 0; Log.Info("Executing batch"); CheckReaders(); AppendInsertsToCmd(); var commandText = _batchCommand.ToString(); _currentBatch.CommandText = commandText; LogCommand(_currentBatch); Prepare(_currentBatch); int rowsAffected; try { rowsAffected = _currentBatch.ExecuteNonQuery(); } catch (Exception e) { Log.Error("Error executing batch.", e); throw; } Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected); _totalExpectedRowsAffected = 0; _currentBatch = null; _batchCommand = null; _parameterCounter = 0; }