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
Comments
- Anonymous
January 11, 2008
How do I restrict access to an operation to particular Windows users? There are three standard ways of