Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a scenario where we need to do multiple operations but all of those should be atomic which includes first writing rows in a table and after that using the Id for those rows writing a file for each of those on a network path and followed by writing to another table rows.

What i need here is all of this should be atomic operation, i.e. all steps should complete successfully, if any one of the process fails for some reason i want the changes done in that context to be rolled back.

I am aware of the TransactionScope class we use in ADO.Net and Entity Framework. But i need some mechanism to do these I/O operations and db action in one transaction.

What I have tried:

I have tried using TransactionScope but cannot figure out how to use that for both operations. It normally works for DB operation but not sure how it will behave for Disk I/O operation like creating a file.
Posted
Updated 14-Nov-18 3:34am

1 solution

Hi,

As far as I know, you can use Transactional File Manager which is a .NET API that supports including file system operations such as file copy, move, delete, append, etc. in a transaction. However, this API is in fact a wrapper around Transactional NTFS

If this did not solve your problem then please leave a comment and I will assist you by improving my solution until your problem gets solved.

Cheers,
AH
 
Share this answer
 
v2
Comments
Ehsan Sajjad 18-Nov-18 23:41pm    
i had saw while searching but thought there might be more better approach, but i think i need to stick to this library for now. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900