Welcome to MSDN Blogs Sign in | Join | Help

Suppressing Transactions During an Operation

Service operations have a declarative attribute for automatically placing the operation within a transaction. Is it possible to do non-transactional work within a transacted operation without having to do everything by hand?

Yes. This is most easily done by creating a transaction scope that suppresses the ambient transaction. Here's a code example that uses TransactionScopeOption.Suppress:

using (TransactionScope s = new TransactionScope(TransactionScopeOption.Suppress))
{
...
s.Complete();
}

Creating the transaction scope excludes the contained operations from the ambient transaction but doesn't have any effect if no transaction is present. Calling Complete in this case isn't required but is good form.

Next time: Not Omitting the XML Declaration

Published Friday, January 11, 2008 5:00 AM by Nicholas Allen

Comments

Friday, January 11, 2008 3:40 PM by Nicholas Allen's Indigo Blog

# Demanding Permissions

How do I restrict access to an operation to particular Windows users? There are three standard ways of

New Comments to this post are disabled
 
Page view tracker