public void CreateSelectIncrementalChanges(SyncFilter filter = null) { var commandName = this.mySqlObjectNames.GetCommandName(DbCommandType.SelectChanges).name; Func <MySqlCommand> cmdWithoutFilter = () => BuildSelectIncrementalChangesCommand(null); CreateProcedureCommand(cmdWithoutFilter, commandName); if (filter != null) { filter.ValidateColumnFilters(this.tableDescription); commandName = this.mySqlObjectNames.GetCommandName(DbCommandType.SelectChangesWithFilters, filter).name; Func <MySqlCommand> cmdWithFilter = () => BuildSelectIncrementalChangesCommand(filter); CreateProcedureCommand(cmdWithFilter, commandName); } }
private void DropProcedure(DbCommandType procType, SyncFilter filter = null) { var commandName = this.mySqlObjectNames.GetCommandName(procType).name; var commandText = $"drop procedure if exists {commandName}"; bool alreadyOpened = connection.State == ConnectionState.Open; try { if (!alreadyOpened) { connection.Open(); } using (var command = new MySqlCommand(commandText, connection)) { if (transaction != null) { command.Transaction = transaction; } command.ExecuteNonQuery(); } if (filter != null) { using (var command = new MySqlCommand()) { if (!alreadyOpened) { this.connection.Open(); } if (this.transaction != null) { command.Transaction = this.transaction; } filter.ValidateColumnFilters(this.tableDescription); var commandNameWithFilter = this.mySqlObjectNames.GetCommandName(DbCommandType.SelectChangesWithFilters, filter).name; command.CommandText = $"DROP PROCEDURE {commandNameWithFilter};"; command.Connection = this.connection; command.ExecuteNonQuery(); } } } catch (Exception ex) { Debug.WriteLine($"Error during DropProcedureCommand : {ex}"); throw; } finally { if (!alreadyOpened && connection.State != ConnectionState.Closed) { connection.Close(); } } }