/// <inheritdoc /> public override void Commit() { if (Interlocked.Exchange(ref _cleanup, 1L) != 0L) { return; } _command.SafelyDispose(); _transaction.SafelyCommit(); _transaction.SafelyDispose(); _connection.SafelyClose(); _connection.SafelyDispose(); }
/// <inheritdoc /> public ICollectionSaver CreateCollectionSaver() { if (_targetController.Cleanup(out var border)) { //something were deleted from the file system //so we need to delete obsolete records from the DB CleanupDatabase(border); } SqlConnection? connection = null; SqlTransaction?transaction = null; try { connection = new SqlConnection(_connectionString); connection.Open(); transaction = connection.BeginTransaction(); return(new SqlServerCollectionSaver( connection, transaction, _tableName, _targetController )); } catch { transaction?.SafelyDispose(); connection?.SafelyDispose(); throw; } }