mercredi 24 août 2016

How to implement batch updates as unit of work when a transaction is already defined?

For my application, I need to implement a way to support batch operations (e.g. updating/inserting multiple entries in a database). However, the API provided to me supports only a change to a single entry as a transaction; it doesn't support atomic changes to multiple entries or rollback if sequential commands fail, etc.

To my understanding I need a unit of work pattern to make all changes succeed or fail at the same time, but this API is my restriction. I've found other unit of work patterns online, but they use TransactionScope and/or the Entity framework, which aren't compatible with my application.

I can perform independent changes to the entries and record the progress of each operation in a table, then conclude all changes succeeded when the table shows this. It seems a bit messy, and I'm reluctant to come up with my own commit logic if this scenario is already solved.

Is there a better way I can implement batch operations when a transaction is already defined for a single entry?

Aucun commentaire:

Enregistrer un commentaire