Table of Contents

Class NpgsqlBatchCommand

Namespace
Npgsql
Assembly
Npgsql.dll
public sealed class NpgsqlBatchCommand : DbBatchCommand
Inheritance
NpgsqlBatchCommand
Inherited Members

Constructors

NpgsqlBatchCommand()

Initializes a new NpgsqlBatchCommand.

public NpgsqlBatchCommand()

NpgsqlBatchCommand(string)

Initializes a new NpgsqlBatchCommand.

public NpgsqlBatchCommand(string commandText)

Parameters

commandText string

The text of the NpgsqlBatchCommand.

Properties

AppendErrorBarrier

Appends an error barrier after this batch command. Defaults to the value of EnableErrorBarriers on the batch.

public bool? AppendErrorBarrier { get; set; }

Property Value

bool?

Remarks

By default, any exception in a command causes later commands in the batch to be skipped, and earlier commands to be rolled back. Appending an error barrier ensures that errors from this command (or previous ones) won't cause later commands to be skipped, and that errors from later commands won't cause this command (or previous ones) to be rolled back).

Note that if the batch is executed within an explicit transaction, the first error places the transaction in a failed state, causing all later commands to fail in any case. As a result, this option is useful mainly when there is no explicit transaction.

At the PostgreSQL wire protocol level, this corresponds to inserting a Sync message after this command, rather than grouping all the batch's commands behind a single terminating Sync.

Controlling error barriers on a command-by-command basis is an advanced feature, consider enabling error barriers for the entire batch via EnableErrorBarriers.

CanCreateParameter

Returns whether the CreateParameter() method is implemented.

public bool CanCreateParameter { get; }

Property Value

bool

CommandText

public override string CommandText { get; set; }

Property Value

string

CommandType

public override CommandType CommandType { get; set; }

Property Value

CommandType

DbParameterCollection

protected override DbParameterCollection DbParameterCollection { get; }

Property Value

DbParameterCollection

OID

For an INSERT, the object ID of the inserted row if RecordsAffected is 1 and the target table has OIDs; otherwise 0.

public uint OID { get; }

Property Value

uint

Parameters

public NpgsqlParameterCollection Parameters { get; }

Property Value

NpgsqlParameterCollection

RecordsAffected

public override int RecordsAffected { get; }

Property Value

int

Rows

The number of rows affected or retrieved.

public ulong Rows { get; }

Property Value

ulong

Remarks

See the command tag in the CommandComplete message for the meaning of this value for each StatementType, https://www.postgresql.org/docs/current/static/protocol-message-formats.html

StatementType

Specifies the type of query, e.g. SELECT.

public StatementType StatementType { get; }

Property Value

StatementType

Methods

CreateParameter()

Creates a new instance of a NpgsqlParameter object.

public NpgsqlParameter CreateParameter()

Returns

NpgsqlParameter

An NpgsqlParameter object.

ToString()

Returns the CommandText.

public override string ToString()

Returns

string