/// <summary> /// Execute the query and return the count of modified rows /// </summary> /// <returns>Count of modified rows</returns> public async virtual Task <int> ExecuteNonQueryAsync() { ResetException(); try { // Commom operations before execution this.OperationsBeforeExecution(); // Send the request to the Database server int rowsAffected = 0; if (this.Command.CommandText.Length > 0) { if (Retry.IsActivated()) { rowsAffected = await Retry.ExecuteCommandOrRetryIfErrorOccuredAsync(async() => await this.Command.ExecuteNonQueryAsync()); } else { rowsAffected = await this.Command.ExecuteNonQueryAsync(); } } // Action After Execution if (this.ActionAfterExecution != null) { var tables = new Schema.DataTable[] { new Schema.DataTable("ExecuteNonQuery", "Result", rowsAffected) }; this.ActionAfterExecution.Invoke(this, tables); int?newValue = tables[0].Rows[0][0] as int?; rowsAffected = newValue.HasValue ? newValue.Value : 0; } return(rowsAffected); } catch (DbException ex) { return(ThrowSqlExceptionOrDefaultValue <int>(ex)); } }