Apply() public method

public Apply ( NpgsqlCommand cmd ) : void
cmd Npgsql.NpgsqlCommand
return void
コード例 #1
0
        public void Execute(NpgsqlCommand cmd, Action <NpgsqlCommand> action = null)
        {
            buildConnection();

            RequestCount++;

            if (action == null)
            {
                action = c => c.ExecuteNonQuery();
            }

            _connection.Apply(cmd);
            try
            {
                action(cmd);
                Logger.LogSuccess(cmd);
            }
            catch (NpgsqlException e)
                when(e.Message.IndexOf(EventContracts.UnexpectedMaxEventIdForStream, StringComparison.Ordinal) > -1)
                {
                    Logger.LogFailure(cmd, e);
                    throw new EventStreamUnexpectedMaxEventIdException(e);
                }
            catch (NpgsqlException e)
            {
                Logger.LogFailure(cmd, e);
                throw new MartenCommandException(cmd, e);
            }
            catch (Exception e)
            {
                Logger.LogFailure(cmd, e);
                throw;
            }
        }
コード例 #2
0
        public int Execute(NpgsqlCommand cmd)
        {
            buildConnection();

            RequestCount++;

            _connection.Apply(cmd);

            try
            {
                var returnValue = _retryPolicy.Execute(cmd.ExecuteNonQuery);
                Logger.LogSuccess(cmd);

                return(returnValue);
            }
            catch (Exception e)
            {
                handleCommandException(cmd, e);
                throw;
            }
        }
コード例 #3
0
        public void Execute(NpgsqlCommand cmd, Action <NpgsqlCommand> action = null)
        {
            buildConnection();

            RequestCount++;

            if (action == null)
            {
                action = c => c.ExecuteNonQuery();
            }

            _connection.Apply(cmd);
            try
            {
                _retryPolicy.Execute(() => action(cmd));
                Logger.LogSuccess(cmd);
            }
            catch (Exception e)
            {
                handleCommandException(cmd, e);
                throw;
            }
        }