TransactionScopeOption - what no "Supports"?

I'm in the process of converting a .net 1.1 program to use System.Transactions. However, I've hit a problem. The current code creates a ES version of a transaction scope and sets the equiv' TransactionScopeOption to "Supports" which means enlist in a transaction if one is there otherwise don't bother. However in System.Transactions there only seems to be {Required|RequriesNew|Supress}. I don't want to have to a put an "If" around each call and I'd rather not have to wrap the TransactionScope object but what choice do I have?
[556 byte] By [pkr2000] at [2008-2-12]
# 1

Hi.

In general, the System.Transactions translation of COM+ 'Supports' should be TransactionScopeOption.Required. However, as I'm sure you know, this does have a different semantic: 'Required' will either use the current transaction if one is present, or create a new transaction if not. If your program's correctness actually depends on not having a transaction present when one is not provided, then 'Required' will not be the correct translation and you will need that 'if' statement. I doubt that this is the case, but I wanted to make sure that the distinction was clear.

I should point out that the concept of 'Supports' was not brought forward into System.Transactions (or into WCF, for that matter) because it is difficult to imagine a correct program where transactions are truly optional. The most common pattern we've seen for the use of 'Supports' is the case where a single resource manager is used and the use of a local transaction for that one operation is in fact a no-op. In that case, using 'Supports' instead of 'Requires' can be a performance optimization in that it removes the overhead of enlisting the resource manager with MSDTC. The risk, of course, is that the program will become incorrect if more transactional resources are added to the 'optional' execution path, because transactions actually never were optional.

We have attemped to address this issue In System.Transactions by ensuring that the overhead of creating local transactions is as low as possible. For example, with SQL Server 2005 there is virtually no difference in performance between creating a local System.Transactions transaction and using a native SQL transaction. Other resource managers may suffer more of a performance penalty until they are adapted to work with System.Transactions transaction promotion.

Let me know if you have further questions.

MaxFeingold-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...
# 2
I feared that was the case, although in my example the requirement is simple. I have a client where the user can choose to run under a transaction and take loads longer (already posted about that bug) or if they're sure they can restore the data themselves they can run lots faster without a transaction. Hence a simple boolean is passed into the business layer where it simply sets the TX option to supports or required. Oh well, an IF it will have to be. Thanks for the reply.
pkr2000 at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Transactions Programming...

Software Development for Windows Vista

Site Classified