private AbpUnitOfWorkOptions CreateOptions(IAbpMethodInvocation invocation, [CanBeNull] UnitOfWorkAttribute unitOfWorkAttribute)
        {
            var options = new AbpUnitOfWorkOptions();

            unitOfWorkAttribute?.SetOptions(options);

            if (unitOfWorkAttribute?.IsTransactional == null)
            {
                options.IsTransactional = _defaultOptions.CalculateIsTransactional(
                    autoValue: !invocation.Method.Name.StartsWith("Get", StringComparison.InvariantCultureIgnoreCase)
                    );
            }

            return(options);
        }
Пример #2
0
        //TODO: More constructors!

        public virtual void SetOptions(AbpUnitOfWorkOptions options)
        {
            if (IsTransactional.HasValue)
            {
                options.IsTransactional = IsTransactional.Value;
            }

            if (Timeout.HasValue)
            {
                options.Timeout = Timeout;
            }

            if (IsolationLevel.HasValue)
            {
                options.IsolationLevel = IsolationLevel;
            }
        }
Пример #3
0
        public IUnitOfWork Begin(AbpUnitOfWorkOptions options, bool requiresNew = false)
        {
            Check.NotNull(options, nameof(options));

            var currentUow = Current;

            if (currentUow != null && !requiresNew)
            {
                return(new ChildUnitOfWork(currentUow));
            }

            var unitOfWork = CreateNewUnitOfWork();

            unitOfWork.Initialize(options);

            return(unitOfWork);
        }
Пример #4
0
        public bool TryBeginReserved(string reservationName, AbpUnitOfWorkOptions options)
        {
            Check.NotNull(reservationName, nameof(reservationName));

            var uow = _ambientUnitOfWork.UnitOfWork;

            //Find reserved unit of work starting from current and going to outers
            while (uow != null && !uow.IsReservedFor(reservationName))
            {
                uow = uow.Outer;
            }

            if (uow == null)
            {
                return(false);
            }

            uow.Initialize(options);

            return(true);
        }
Пример #5
0
 public void Initialize(AbpUnitOfWorkOptions options)
 {
     _parent.Initialize(options);
 }