Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

When to use TransactionOption.Supported

Posted on 2003-12-08
9
581 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 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