Ejemplo n.º 1
0
        public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options)
        {
            var outerUow = _currentUnitOfWorkProvider.Current;

            if (options.Scope == TransactionScopeOption.Required && outerUow != null)
            {
                return(new InnerUnitOfWorkCompleteHandle());
            }

            var uow = _serviceProvider.GetService <IUnitOfWork>();

            uow.Completed += (sender, args) =>
            {
                _currentUnitOfWorkProvider.Current = null;
            };

            uow.Failed += (sender, args) =>
            {
                _currentUnitOfWorkProvider.Current = null;
            };

            uow.Disposed += (sender, args) =>
            {
                uow.Dispose();
            };

            uow.Begin(options);

            // Inherit connectionStringName from outer UOW
            if (outerUow != null)
            {
                uow.SetConnectionStringName(outerUow.GetConnectionStringName());
            }

            _currentUnitOfWorkProvider.Current = uow;

            return(uow);
        }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 public virtual void InitOptions(UnitOfWorkOptions options)
 {
     Options = options;
 }
Ejemplo n.º 3
0
 public void InitOptions(UnitOfWorkOptions options)
 {
     this.Options = options;
 }