This is what we have used below in the past without any issues.

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]

      public class TransactionAttribute : ActionFilterAttribute

      {

            private readonly TimeSpan _timeout;

            private readonly IsolationLevel _isolationLevel;

            private TransactionScope _currentTransaction;



            public TransactionAttribute() : this(IsolationLevel
.Serializable)

            {

            }



            public TransactionAttribute(IsolationLevel isolationLevel) :
this(isolationLevel, TimeSpan.FromSeconds(30))

            {

            }



            public TransactionAttribute(IsolationLevel isolationLevel,
TimeSpan timeout)

            {

                  _isolationLevel = isolationLevel;

                  _timeout = timeout;

            }



            public override void
OnActionExecuting(ActionExecutingContextfilterContext)

            {

                  var transactionOptions = new
TransactionOptions{IsolationLevel = _isolationLevel, Timeout =
_timeout};

                  _currentTransaction = new TransactionScope(
TransactionScopeOption.Required, transactionOptions);

            }



            public override void
OnActionExecuted(ActionExecutedContextfilterContext)

            {

                  using(_currentTransaction)

                  {

                        if(filterContext.Exception != null)

                              _currentTransaction.Complete();

                  }

            }

      }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to