public async Task <OperationResult <List <Serving> > > ListAsync()
        {
            try
            {
                var trOps = new TransactionOptions
                {
                    IsolationLevel = IsolationLevel.ReadCommitted,
                    Timeout        = TimeSpan.FromSeconds(30)
                };

                using var transactionScope = new TransactionScope(TransactionScopeOption.Required, trOps, TransactionScopeAsyncFlowOption.Enabled);
                var result = await _dao.ListAsync();

                transactionScope.Complete();

                return(new OperationResult <List <Serving> >()
                {
                    Success = true, Result = result
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <List <Serving> >()
                {
                    Success = false, Exception = e
                });
            }
        }
예제 #2
0
        public async virtual Task <OperationResult <List <Serving> > > ListAsync()
        {
            try
            {
                using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
                var result = await _dao.ListAsync();

                transactionScope.Complete();
                return(new OperationResult <List <Serving> > {
                    Result = result, Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <List <Serving> >()
                {
                    Success = false, Exception = e
                });
            }
        }
예제 #3
0
        public async Task <OperationResult <List <Serving> > > ListAsync()
        {
            try
            {
                using (var ts = new TransactionScope(TransactionScopeOption.Required, opts, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var res = await _dao.ListAsync();

                    ts.Complete();
                    return(new OperationResult <List <Serving> >()
                    {
                        Success = true, Result = res
                    });
                }
            }
            catch (Exception e)
            {
                return(new OperationResult <List <Serving> >()
                {
                    Success = false, Exception = e
                });
            }
        }