As you may know, Suppress scope will suppress the current ambient transaction, and if there is no ambient transaction present, it will not create any transaction at all.
But there is one thing you may not know, which is, if there is another TransactionScope further down the stack it will react as if there was no ambient transaction (and create one if necessary).
So if you have 3 scopes as follows: .Required -> .Suppress -> .Required: Then 2 transactions will be created. The innermost TransactionScope with .Required will see that there is no ambient transaction and will creates one for itself.
One thing to remember, to keep the code consistence, always call scope.Complete() at the end of your suppress TransactionScope even you know logically there will be no transaction created. There will be no any overhead caused by doing that.
Wednesday, 24 February 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment