Beispiel #1
0
        /// <summary>
        /// 执行带事务的操作
        /// </summary>
        /// <typeparam name="TResultObject">返回对象类型</typeparam>
        /// <param name="func">要执行的具体业务</param>
        /// <param name="throwException">是否抛出异常</param>
        /// <returns>返回结果对象</returns>
        public static TResultObject ExecuteTransaction <TResultObject>(Func <TResultObject> func, bool throwException = false)
            where TResultObject : IResultObject, new()
        {
            var opt = new SimpleTransactionServiceOption <DefaultRequest, TResultObject>(new DefaultRequest(), null, func);

            return(opt.DoExecute(throwException));
        }
Beispiel #2
0
        /// <summary>
        /// 执行带事务的操作
        /// </summary>
        /// <typeparam name="TRequest">请求对象类型</typeparam>
        /// <typeparam name="TResultObject">返回对象类型</typeparam>
        /// <param name="request">请求</param>
        /// <param name="requestValidator">请求验证器</param>
        /// <param name="func">要执行的具体业务</param>
        /// <param name="throwException">是否抛出异常</param>
        /// <returns>返回结果对象</returns>
        public static TResultObject ExecuteTransaction <TRequest, TResultObject>(TRequest request, IValidator requestValidator, Func <TResultObject> func, bool throwException = false)
            where TRequest : IRequest
            where TResultObject : IResultObject, new()
        {
            var opt = new SimpleTransactionServiceOption <TRequest, TResultObject>(request, requestValidator, func);

            return(opt.DoExecute(throwException));
        }