C# Class Npgsql.NpgsqlCommand

Represents a SQL statement or function (stored procedure) to execute against a PostgreSQL database. This class cannot be inherited.
Inheritance: System.Data.Common.DbCommand, ICloneable
Mostra file Open project: undeadlabs/Npgsql Class Usage Examples

Private Properties

Property Type Description
AddFunctionColumnListSupport void
AppendCommandReplacingParameterValues void
AppendParameterPlaceHolder void
AppendParameterPlaceHolders void
AppendParameterValue void
AppendParameterValues void
BindParameters void
BuildParameterNameCharacterTable System.Array
CheckConnectionState void
CheckFunctionNeedsColumnDefinitionList System.Boolean
ClearPoolAndCreateException NpgsqlException
ExecuteBlind void
ExecuteBlind void
ExecuteBlind void
ExecuteSetStatementTimeoutBlind void
GetCommandText byte[]
GetCommandText byte[]
GetDistinctTrimmedCommands StringChunk[]
GetExecuteCommandText byte[]
GetReader ForwardsOnlyDataReader
ICloneable Object
IsParamNameChar bool
NpgsqlCommand System
NpgsqlCommand System
PrepareInternal void
SetCommandTimeout void
UnPrepare void

Public Methods

Method Description
Cancel ( ) : void

Attempts to cancel the execution of a NpgsqlCommand.

This Method isn't implemented yet.

Clone ( ) : NpgsqlCommand

Create a new command based on this one.

CreateParameter ( ) : Npgsql.NpgsqlParameter

Creates a new instance of a NpgsqlParameter object.

ExecuteNonQuery ( ) : Int32

Executes a SQL statement against the connection and returns the number of rows affected.

ExecuteReader ( ) : Npgsql.NpgsqlDataReader

Sends the CommandText to the Connection and builds a NpgsqlDataReader.

ExecuteReader ( CommandBehavior cb ) : Npgsql.NpgsqlDataReader

Sends the CommandText to the Connection and builds a NpgsqlDataReader using one of the CommandBehavior values.

Currently the CommandBehavior parameter is ignored.

ExecuteScalar ( ) : Object

Executes the query, and returns the first column of the first row in the result set returned by the query. Extra columns or rows are ignored.

NpgsqlCommand ( String cmdText ) : System

Initializes a new instance of the NpgsqlCommand class with the text of the query.

NpgsqlCommand ( String cmdText, NpgsqlConnection connection ) : System

Initializes a new instance of the NpgsqlCommand class with the text of the query and a NpgsqlConnection.

NpgsqlCommand ( String cmdText, NpgsqlConnection connection, NpgsqlTransaction transaction ) : System

Initializes a new instance of the NpgsqlCommand class with the text of the query, a NpgsqlConnection, and the NpgsqlTransaction.

Prepare ( ) : void

Creates a prepared version of the command on a PostgreSQL server.

Protected Methods

Method Description
CreateDbParameter ( ) : DbParameter

Creates a new instance of an DbParameter object.

ExecuteDbDataReader ( CommandBehavior behavior ) : System.Data.Common.DbDataReader

Sends the CommandText to the Connection and builds a NpgsqlDataReader using one of the CommandBehavior values.

Private Methods

Method Description
AddFunctionColumnListSupport ( Stream st ) : void
AppendCommandReplacingParameterValues ( Stream dest, string src, int begin, int length, bool prepare, bool forExtendedQuery ) : void

Append a region of a source command text to an output command, performing parameter token substitutions.

AppendParameterPlaceHolder ( Stream dest, Npgsql.NpgsqlParameter parameter, int paramNumber ) : void
AppendParameterPlaceHolders ( Stream dest ) : void
AppendParameterValue ( Stream dest, Npgsql.NpgsqlParameter parameter ) : void
AppendParameterValues ( Stream dest ) : void
BindParameters ( ) : void

This method binds the parameters from parameters collection to the bind message.

BuildParameterNameCharacterTable ( ) : Array
CheckConnectionState ( ) : void

This method checks the connection state to see if the connection is set or it is open. If one of this conditions is not met, throws an InvalidOperationException

CheckFunctionNeedsColumnDefinitionList ( ) : System.Boolean
ClearPoolAndCreateException ( Exception e ) : NpgsqlException
ExecuteBlind ( NpgsqlConnector connector, NpgsqlQuery query, int timeout ) : void
ExecuteBlind ( NpgsqlConnector connector, byte command, int timeout = 20 ) : void

Internal query shortcut for use in cases where the number of affected rows is of no interest.

ExecuteBlind ( NpgsqlConnector connector, string command, int timeout = 20 ) : void

Internal query shortcut for use in cases where the number of affected rows is of no interest.

ExecuteSetStatementTimeoutBlind ( NpgsqlConnector connector, int timeout ) : void

Special adaptation of ExecuteBlind() that sets statement_timeout. This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(), which will cause an endless recursive loop.

GetCommandText ( ) : byte[]

This method substitutes the Parameters, if exist, in the command to their actual values. The parameter name format is :ParameterName.

GetCommandText ( bool prepare, bool forExtendQuery ) : byte[]

Process this.commandText, trimming each distinct command and substituting paramater tokens.

GetDistinctTrimmedCommands ( string src ) : StringChunk[]

Find the beginning and end of each distinct SQL command and produce a list of descriptors, one for each command. Commands described are trimmed of leading and trailing white space and their terminating semi-colons.

GetExecuteCommandText ( ) : byte[]
GetReader ( CommandBehavior cb ) : ForwardsOnlyDataReader
ICloneable ( ) : Object

Create a new command based on this one.

IsParamNameChar ( char ch ) : bool
NpgsqlCommand ( ) : System
NpgsqlCommand ( String cmdText, NpgsqlConnector connector, int CommandTimeout = 20 ) : System

Used to execute internal commands.

PrepareInternal ( ) : void
SetCommandTimeout ( ) : void

Releases the resources used by the NpgsqlCommand.

UnPrepare ( ) : void

Method Details

Cancel() public method

Attempts to cancel the execution of a NpgsqlCommand.
This Method isn't implemented yet.
public Cancel ( ) : void
return void

Clone() public method

Create a new command based on this one.
public Clone ( ) : NpgsqlCommand
return NpgsqlCommand

CreateDbParameter() protected method

Creates a new instance of an DbParameter object.
protected CreateDbParameter ( ) : DbParameter
return System.Data.Common.DbParameter

CreateParameter() public method

Creates a new instance of a NpgsqlParameter object.
public CreateParameter ( ) : Npgsql.NpgsqlParameter
return Npgsql.NpgsqlParameter

ExecuteDbDataReader() protected method

Sends the CommandText to the Connection and builds a NpgsqlDataReader using one of the CommandBehavior values.
protected ExecuteDbDataReader ( CommandBehavior behavior ) : System.Data.Common.DbDataReader
behavior CommandBehavior One of the CommandBehavior values.
return System.Data.Common.DbDataReader

ExecuteNonQuery() public method

Executes a SQL statement against the connection and returns the number of rows affected.
public ExecuteNonQuery ( ) : Int32
return System.Int32

ExecuteReader() public method

Sends the CommandText to the Connection and builds a NpgsqlDataReader.
public ExecuteReader ( ) : Npgsql.NpgsqlDataReader
return Npgsql.NpgsqlDataReader

ExecuteReader() public method

Sends the CommandText to the Connection and builds a NpgsqlDataReader using one of the CommandBehavior values.
Currently the CommandBehavior parameter is ignored.
public ExecuteReader ( CommandBehavior cb ) : Npgsql.NpgsqlDataReader
cb CommandBehavior One of the CommandBehavior values.
return Npgsql.NpgsqlDataReader

ExecuteScalar() public method

Executes the query, and returns the first column of the first row in the result set returned by the query. Extra columns or rows are ignored.
public ExecuteScalar ( ) : Object
return Object

NpgsqlCommand() public method

Initializes a new instance of the NpgsqlCommand class with the text of the query.
public NpgsqlCommand ( String cmdText ) : System
cmdText String The text of the query.
return System

NpgsqlCommand() public method

Initializes a new instance of the NpgsqlCommand class with the text of the query and a NpgsqlConnection.
public NpgsqlCommand ( String cmdText, NpgsqlConnection connection ) : System
cmdText String The text of the query.
connection NpgsqlConnection A NpgsqlConnection that represents the connection to a PostgreSQL server.
return System

NpgsqlCommand() public method

Initializes a new instance of the NpgsqlCommand class with the text of the query, a NpgsqlConnection, and the NpgsqlTransaction.
public NpgsqlCommand ( String cmdText, NpgsqlConnection connection, NpgsqlTransaction transaction ) : System
cmdText String The text of the query.
connection NpgsqlConnection A NpgsqlConnection that represents the connection to a PostgreSQL server.
transaction NpgsqlTransaction The NpgsqlTransaction in which the NpgsqlCommand executes.
return System

Prepare() public method

Creates a prepared version of the command on a PostgreSQL server.
public Prepare ( ) : void
return void