Exemplo n.º 1
0
        public static IFluentCommandAndQueryRepository WithUnitOfWork(IsolationLevel isoLevel, TransactionScopeOption scopeOption, bool shouldAutomaticallyRollBackOnTransactionException = true, bool shouldThrowOnException = true, IExceptionHandler exceptionHandler = null)
        {
            var unitOfWorkData = new UnitOfWorkData {
                UnitOfWork = new UnitOfWork(exceptionHandler, isoLevel, scopeOption), ShouldAutomaticallyRollBackOnTransactionException = shouldAutomaticallyRollBackOnTransactionException, ShouldThrowOnException = shouldThrowOnException
            };

            return(new FluentCommandAndQueryRepository(unitOfWorkData));
        }
        public static IFluentCommandAndQueryRepository WithUnitOfWork <TUnitOfWork>(TUnitOfWork unitOfWork, bool shouldAutomaticallyRollBackOnTransactionException = true, bool shouldThrowOnException = true)
            where TUnitOfWork : class, IUnitOfWork
        {
            ContractUtility.Requires <ArgumentNullException>(unitOfWork.IsNotNull(), "unitOfWork instance cannot be null");
            var unitOfWorkData = new UnitOfWorkData {
                UnitOfWork = unitOfWork, ShouldAutomaticallyRollBackOnTransactionException = shouldAutomaticallyRollBackOnTransactionException, ShouldThrowOnException = shouldThrowOnException
            };

            return(new FluentCommandAndQueryRepository(unitOfWorkData));
        }
        public static IFluentCommandAndQueryRepository WithDefaultUnitOfWork(bool shouldAutomaticallyRollBackOnTransactionException = true, bool shouldThrowOnException = true)
        {
            var isoLevel       = IsolationLevel.ReadCommitted;
            var scopeOption    = TransactionScopeOption.RequiresNew;
            var unitOfWorkData = new UnitOfWorkData {
                UnitOfWork = new UnitOfWork(isoLevel, scopeOption), ShouldAutomaticallyRollBackOnTransactionException = shouldAutomaticallyRollBackOnTransactionException, ShouldThrowOnException = shouldThrowOnException
            };

            return(new FluentCommandAndQueryRepository(unitOfWorkData));
        }