Thoughts from Dan Miser RSS 2.0
# Tuesday, November 20, 2007

I can't think of one good reason for anyone to ever use System.Transactions.TransactionScope. There have been a lot of positive articles written about this class over time. I don't want to link to any of them because then you might be tempted to believe that this class is actually useful - as I did. I wanted to believe. I really did. Then I actually used it.

About 6 months ago, I tried to use TransactionScope, and things were great. I developed the system and had no issues. Then, when deploying to a client, I found out that it doesn't work with MSSQL 2000. I thought the requirements were ironed out that we were using MSSQL 2005, but it turns out that wasn't the case after all. Sure, there are ways to get it to work with MSSQL 2000, but at that point, I figured I'd just use the SqlTransaction directly.

Fast forward to today. I see MSSQL Compact Edition 3.5 is shipping, and it claims support for TransactionScope on desktop applications. Perfect! However, my unit testing shows that connections won't enlist in the transaction when using TransactionScope. To make matters worse, TransactionScope behaves differently when using MSSQL 2005 and MSSQL CE. So much for the ubiquitous advice of  using TransactionScope in unit tests.

My advice? Feel free to use TransactionScope if you will only ever hit MSSQL 2005 on the backend. Even then, I would triple check that it works properly because I have lost all faith in this class. As for me, I plan on ignoring this class completely due to the ill-implemented effort.

Tuesday, November 20, 2007 10:36:12 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)