示例#1
0
 public OperationResult <Restaurant> Read(Guid id)
 {
     try
     {
         var transactionOptions = new TransactionOptions
         {
             IsolationLevel = IsolationLevel.ReadCommitted,
             Timeout        = TimeSpan.FromSeconds(30)
         };
         var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
         var result           = _dao.Read(id);
         transactionScope.Complete();
         return(new OperationResult <Restaurant>()
         {
             Success = true, Result = result
         });
     }
     catch (Exception e)
     {
         return(new OperationResult <Restaurant>()
         {
             Success = false, Exception = e
         });
     }
 }
示例#2
0
 public virtual OperationResult <Restaurant> Read(Guid id)
 {
     try
     {
         using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
         var result = _dao.Read(id);
         transactionScope.Complete();
         return(new OperationResult <Restaurant> {
             Result = result, Success = true
         });
     }
     catch (Exception e)
     {
         return(new OperationResult <Restaurant>()
         {
             Success = false, Exception = e
         });
     }
 }
 public OperationResult <Restaurant> Read(Guid id)
 {
     try
     {
         using (var ts = new TransactionScope(TransactionScopeOption.Required, opts, TransactionScopeAsyncFlowOption.Enabled))
         {
             var res = _dao.Read(id);
             ts.Complete();
             return(new OperationResult <Restaurant>()
             {
                 Success = true, Result = res
             });
         }
     }
     catch (Exception e)
     {
         return(new OperationResult <Restaurant>()
         {
             Success = false, Exception = e
         });
     }
 }