c# - Transaction between database and a memory task ? -


I want to do some work in the database, then some tasks on the memory (such as changing some values ​​of objects) and I combine I want to work both in one transaction.

I am using EF 4.1 and it only provides me the SaveChanges method which transmits by itself just if SaveChanges does not throw exceptions so I can do some work on memory This is a solution But it breaks the architecture of the application. Because SaveChanges is not said before that task Tasks can not know whether the savings changelog will succeed or fail in the future when it will be called.

Is any transaction possible between database and memory functions?

If so, how can we do this?

MSDN has an excellent article, explaining how to create a transactional wrapper around in-memory type.

At its core, you want to implement. Once you implement it for in-memory type, you want to be a part of the transaction, you will have to register it by calling on the transaction to register an example of notification on the transaction.

Normally, you have to call EnlistVolatile to see if the static static is not zero, and if it is not, (for example it What to do in order to do so to register themselves).

However, when you know that after the transaction (you have created, for example), you want that you want your instances S) can recruit.

If you do not want to go through the above, you can subscribe to the nearest and change the status of your memory variable on the basis of transaction . For event handlers.

You can get from transaction . In the TransactionInformation category, one indicates that the transaction returns a value from what is (committed, canceled, etc.).

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -