System.Transactions.TransactionScope and IDbTransaction
I've enjoyed reading about the new System.Transactions namespace and the easy to use TransactionScope object. But there was always something that I wasn't sure about, and from questions I've received its clear I wasn't the only one. The question is basically what happens if you have a traditional ADO.NET IDbTransaction and you enclose it in a TransactionScope? I finally got around to testing out this scenario and I'm pleased to report that everything works exactly as you would hope. In other words, even though you may have an IDbTransaction that you have committed, it will still get rolled back if its enclosed in a TransactionScope that does not Complete. This means that you can continue to use all your existing code and libraries that work with IDbTransactions -- and still use the new TransactionScope when you need something more. It also means that I don't need to do anything special for my ORMapper -- I can continue to use IDbTransaction and my users can use the new TransactionScope also. By the way, I knew Access didn't support distributed transactions, but I was pleasantly surprised that I got an exception when I tried out of curiosity. Finally, for all my readers that think this behavior with IDbTransactions should be obvious, I agree but I've also learned to test things instead of assuming.