Is the TransactionScope can be used only for Database/ADO.NET related methods?
Say, I have a Data Access Layer method which performs few activities:
- one activity includes a database update,
- another one is writing to a file,
- and the third one is creating a registry entry.
The method can be considered success only if all the three activities are successful, otherwise it is a failure, and all the preceding activities should be reverted back.
Does TransactionScope supports this? If not, what is the best way of handling such a scenario?
I don’t believe file operations take part in the transactions. It depends on the OS, I think Vista and Win7 do, but older versions do not. A quick search shows a few assemblies you can download to do this. Search for .NET Transactional File Manager on codeplex.
Here is another good link that may work for you: http://petermeinl.wordpress.com/2011/03/13/using-the-net-transactionscope/