private async Task <TResult> ExecuteAsyncImplementation <TResult>(Func <Task <TResult> > func)
        {
            try
            {
                return(await func().ConfigureAwait(continueOnCapturedContext: false));
            }
            catch (Exception ex)
            {
                if (DbExecutionStrategy.UnwrapAndHandleException(ex, SqlAzureRetriableExceptionDetector.ShouldRetryOn))
                {
                    throw new EntityException(Strings.TransientExceptionDetected, ex);
                }

                throw;
            }
        }
 public TResult Execute <TResult>(Func <TResult> operation)
 {
     Check.NotNull <Func <TResult> >(operation, nameof(operation));
     try
     {
         return(operation());
     }
     catch (Exception ex)
     {
         if (DbExecutionStrategy.UnwrapAndHandleException <bool>(ex, new Func <Exception, bool>(ShouldRetryOn)))
         {
             throw new EntityException("TransientExceptionDetected", ex);
         }
         throw;
     }
 }
        public TResult Execute <TResult>(Func <TResult> operation)
        {
            Check.NotNull(operation, "operation");

            try
            {
                return(operation());
            }
            catch (Exception ex)
            {
                if (DbExecutionStrategy.UnwrapAndHandleException(ex, SqlAzureRetriableExceptionDetector.ShouldRetryOn))
                {
                    throw new EntityException(Strings.TransientExceptionDetected, ex);
                }

                throw;
            }
        }
        private static async Task <TResult> ExecuteAsyncImplementation <TResult>(Func <Task <TResult> > func)
        {
            TResult result;

            try
            {
                result = await func().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                if (DbExecutionStrategy.UnwrapAndHandleException <bool>(ex, new Func <Exception, bool>(ShouldRetryOn)))
                {
                    throw new EntityException("TransientExceptionDetected", ex);
                }
                throw;
            }
            return(result);
        }