Esempio n. 1
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var descriptor = context.ActionDescriptor as ControllerActionDescriptor;

            //check if transactions isolation levels were specified for the request and if so, set them in appropriate Unit of Work
            var isolationLevelAttributes      = descriptor.MethodInfo.GetCustomAttributes <TransactionIsolationLevelAttribute>(true);
            var globalIsolationLevelAttribute = isolationLevelAttributes?.SingleOrDefault(x => string.IsNullOrEmpty(x.UnitOfWorkKey));

            //set isolation level for all UoWs
            if (globalIsolationLevelAttribute != null)
            {
                foreach (var uow in _uowPool.GetAll())
                {
                    uow.SetIsolationLevel(globalIsolationLevelAttribute.Level);
                }
            }

            //override the previously set isolation level for specific UoWs
            if (isolationLevelAttributes != null)
            {
                foreach (var attr in isolationLevelAttributes)
                {
                    var uow = _uowPool.Get(attr.UnitOfWorkKey);
                    uow.SetIsolationLevel(attr.Level);
                }
            }
        }
Esempio n. 2
0
 public ReleasesUoW(IUnitOfWorkPool uowPool)
 {
     _uow = uowPool.Get(KEY);
 }
Esempio n. 3
0
 public IssuesUow(IUnitOfWorkPool uowPool)
 {
     _uow = uowPool.Get(KEY);
 }