public void BeginReserved(string reservationName, XqUnitOfWorkOptions options) { if (!TryBeginReserved(reservationName, options)) { throw new XqException($"Could not find a reserved unit of work with reservation name: {reservationName}"); } }
/// <summary> /// 通过<paramref name="options"/>进行<see cref="IUnitOfWork"/>初始化 /// </summary> /// <param name="options"></param> public virtual void Initialize(XqUnitOfWorkOptions options) { XqCheck.NotNull(options, nameof(options)); if (Options != null) { throw new XqException("This unit of work is already initialized before!"); } Options = _defaultOptions.Normalize(options.Clone()); IsReserved = false; }
internal XqUnitOfWorkOptions Normalize(XqUnitOfWorkOptions options) { if (options.IsolationLevel == null) { options.IsolationLevel = IsolationLevel; } if (options.Timeout == null) { options.Timeout = Timeout; } return(options); }
/// <summary> /// 获得一个工作单元,如果<paramref name="requiresNew"/>为False,将把当前的Uow作为一个<see cref="ChildUnitOfWork"/>返回 /// 如果<paramref name="requiresNew"/>为True,创建一个Uow /// </summary> /// <param name="options"></param> /// <param name="requiresNew"></param> /// <returns></returns> public IUnitOfWork Begin(XqUnitOfWorkOptions options, bool requiresNew = false) { XqCheck.NotNull(options, nameof(options)); var currentUow = Current; if (currentUow != null && !requiresNew) { return(new ChildUnitOfWork(currentUow)); } var unitOfWork = CreateNewUnitOfWork(); unitOfWork.Initialize(options); return(unitOfWork); }
public bool TryBeginReserved(string reservationName, XqUnitOfWorkOptions options) { XqCheck.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); }
public void Initialize(XqUnitOfWorkOptions options) { _parent.Initialize(options); }