开发者

Application Transaction + C# + more than one operation

开发者 https://www.devze.com 2023-01-04 13:00 出处:网络
I would Like to ask you, if there is a way to set some operations into transaction. I have problem such like this:

I would Like to ask you, if there is a way to set some operations into transaction. I have problem such like this:

1) Generate File from data from database 2) Encrypt it 3)开发者_如何学Go Send to server

I would like do it in one transaction. Any failured step 1-3 should cause the cancelling transaction.

Best regards,


Yes. Check out TransactionScope and MSDTC.


I dont think you need a transaction for this as you only update the database in your last step. Any failure up to that point does not affect any other data from what you describe in your post.

Update: You may want to look at Volatile Resource Managers


As curious_geek stated it can be achived with a TransactionScope. But it can be tricky to work with transactions, especially when you want to do more than one type of operation per transaction.

Are you even sure that you need a transaction? Cant you just delete the file again if step 2 or 3 fails?

0

精彩评论

暂无评论...
验证码 换一张
取 消