Solved

When to use TransactionOption.Supported

Posted on 2003-12-08
9
582 Views
Last Modified: 2012-06-27
I have a class that requires to be in a Transaction. I therefore have given it the attribute <Transaction(TransactionOption.Required)>
My class also calls methods in other classes which do work that needs to be in the transaction.
Do I have to add an attribute to those classes as well or will they automatically be in the transaction?

If I don't have to, why would any one ever use the TransactionOption.Supported parameter?

0
Comment
Question by:mikexxx
  • 6
  • 3
9 Comments
 
LVL 8

Expert Comment

by:Dranizz
ID: 9897986
Well, if you have many objects in different assemblies that can operate seperatly and together, you can set the transaction object to supported to make them share a transaction if use together.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9897998
You don't have to add option for other classes, class called in the method with the attribute will be in the transaction, if any fails and exception is thrown, than the transaction fails for all and rollbacked, if no exception is thrown, then trnsaction is commited for all.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9903727
Is that good enougth?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:mikexxx
ID: 9903803
I don't think you are correct. I have just created a transaction and called a method in another DLL. When I throw an exception, everything rolls back. The transaction must be containing what was done in the other DLL.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9903839
what option did you use?
0
 

Author Comment

by:mikexxx
ID: 9903861
I created the transaction by having the attribute <Transaction(TransactionOption.Required)>  on the class which inherited ServicedComponent .
The class in the DLL did not inherit ServicedComponent or have any relavent attributes.
0
 
LVL 8

Expert Comment

by:Dranizz
ID: 9903868
Yeah, that's what I told you.
"if any fails and exception is thrown, than the transaction fails for all and rollbacked,"

Everything shares the transaction in the method where you specify the transaction option. With supported, if a transaction is already started then it shares it.

With requiredit shares a transac it exist or create one if not.
With requirednew it creates a root transac.

0
 

Author Comment

by:mikexxx
ID: 9903892
Yes but I was calling stuff in another assembly, without the TransactionOption.Supported
 and yet it still was contained within the transaction.

Since this is the case, my question is, why would I ever need to specify TransactionOption.Supported since it is the default.

0
 
LVL 8

Accepted Solution

by:
Dranizz earned 250 total points
ID: 9904148

In my MCSD book, it says that the configured default value is Required with and IsolationLevel Serializable.
and the unconfigured default value is false.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cossdk/htm/pgservices_transactions_9oj7.asp
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question