/// <summary> /// Peforms operations after the script was applied against the database depending on the result of the queries execution. /// </summary> /// <param name="transaction">The <see cref="MySqlTransaction"/> used</param> private void PostApplyScript(MySqlTransaction transaction) { if (transaction == null) { return; } switch (ScriptResult) { case MySqlStatement.StatementResultType.ConnectionLost: // Since the connection was lost the transaction can't be committed or rolled back, just errored out. break; case MySqlStatement.StatementResultType.NotApplied: case MySqlStatement.StatementResultType.ErrorThrown: transaction.Rollback(); if (_lockedTable) { _wbConnection.UnlockTablesInClientSession(); } if (_createdTable) { _wbConnection.DropTableIfExists(_mySqlTable.TableNameForSqlQueries); } break; case MySqlStatement.StatementResultType.WarningsFound: case MySqlStatement.StatementResultType.Successful: // After commiting the transaction, process rows according to ther result. transaction.Commit(); // Do not convert to LINQ, it will use a Where clause that will consume more time than just skipping the row. foreach (var mySqlRow in ActualStatementRowsList) { if (!mySqlRow.Statement.StatementWasApplied) { continue; } if (mySqlRow.HasConcurrencyWarnings) { mySqlRow.ReflectError(); continue; } if (_refreshRowsDataAfterPush) { mySqlRow.RefreshData(true); } else { mySqlRow.AcceptChanges(); } mySqlRow.ClearErrors(); } break; } }