コード例 #1
0
        /// <summary>
        /// Utility method for executing an Ad-Hoc query or stored procedure without a transaction
        /// </summary>
        /// <param name="policy"></param>
        /// <param name="query">The query command text or name of stored procedure to execute against the data store</param>
        /// <returns>Returns the number of rows affected by this query as a <see cref="int"/></returns>
        public PolicyResult <int> CaptureNonQuery(string query, ISyncPolicy policy)
        {
            //Check for null
            if (policy == null)
            {
                throw new ArgumentNullException(nameof(policy));
            }

            //Return this back to the caller
            return(policy.ExecuteAndCapture(() => ExecuteSQL.ExecuteNonQuery(QueryCommandType, query)));
        }
コード例 #2
0
        /// <summary>
        /// Captures the get data object enumerable asynchronous.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query">The query.</param>
        /// <param name="policy">The policy.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">policy</exception>
        public PolicyResult <IEnumerable <T> > CaptureGetDataObjectEnumerable <T>(string query, ISyncPolicy policy) where T : class
        {
            //Check for null
            if (policy == null)
            {
                throw new ArgumentNullException(nameof(policy));
            }

            //Return this back to the caller
            return(policy.ExecuteAndCapture(() => ExecuteSQL.GetDataObjectEnumerable <T>(QueryCommandType, query)));
        }
コード例 #3
0
 /// <inheritdoc />
 public TResult Handle(TQuery query)
 {
     Guard.NotNull(() => query, query);
     if (_policy == null)
     {
         _policies.Registry.TryGet(TransportPolicyDefinitions.RetryQueryHandler, out _policy);
     }
     if (_policy != null)
     {
         var result = _policy.ExecuteAndCapture(() => _decorated.Handle(query));
         if (result.FinalException != null)
         {
             throw result.FinalException;
         }
         return(result.Result);
     }
     return(_decorated.Handle(query));
 }
コード例 #4
0
        /// <inheritdoc />
        public TOutput Handle(TCommand command)
        {
            Guard.NotNull(() => command, command);

            if (_policy == null)
            {
                _policies.Registry.TryGet(TransportPolicyDefinitions.RetryCommandHandler, out _policy);
            }
            if (_policy == null)
            {
                return(_decorated.Handle(command));
            }
            var result = _policy.ExecuteAndCapture(() => _decorated.Handle(command));

            if (result.FinalException != null)
            {
                throw result.FinalException;
            }
            return(result.Result);
        }
コード例 #5
0
 /// <summary>
 /// Executes the open.
 /// </summary>
 /// <param name="policy">The policy.</param>
 public PolicyResult CaptureOpen(ISyncPolicy policy)
 {
     return(policy.ExecuteAndCapture(() => ExecuteSQL.Connection.Open()));
 }
コード例 #6
0
 /// <summary>
 /// Captures the get data reader asynchronous.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="policy">The policy.</param>
 /// <param name="behavior">The behavior.</param>
 /// <param name="transact">The transact.</param>
 /// <returns></returns>
 public PolicyResult <DbDataReader> CaptureGetDataReader(string query, ISyncPolicy policy, CommandBehavior behavior = CommandBehavior.Default, DbTransaction transact = null)
 {
     return(policy.ExecuteAndCapture(() => ExecuteSQL.GetDbDataReader(QueryCommandType, query, behavior, transact)));
 }