Transaction on objects in C #

I was wondering if there is a way to have a transaction on an object. I ask this question for the following situation:

We transfer our object to our information resource. There we use a transaction to ensure that the database is not corrupted.

In this process, the object can be modified (datechanged, owner, ect ...). But if the transaction failed, the transaction rolls back the transactions in the database, but not on your object.

Thus, your object (which is passed by reference) is incorrect.

I hope there is a solution for this.

+3
source share
4 answers
+2

TransactionScope, , ( ). , , .

+2

I really doubt that you may have transactions on class objects. Perhaps you can configure your code to save the state in another instance and restore it immediately after your rollback statement.

0
source

I use a good OR-Mapper like NHibernate, instead of a user level data, this will take care of you

0
source

Source: https://habr.com/ru/post/1724715/


All Articles