How to create/delete multiple items in a transaction

I am trying to delete multiple items in a SharePoint list with the constraint that either all of the items should be deleted or none of the items should be deleted.

In short, I am looking to create more of a transactional behavior in SharePoint. I have tried using the ProcessBatchData() function but it doesn’t seem to fulfil my requirement. Is there, perhaps, another method that someone knows of to accomplish this goal?

How to create/delete multiple items in a transaction