C# Class Npgsql.NpgsqlCommandBuilder

Inheritance: System.ComponentModel.Component
显示文件 Open project: npgsql/npgsql Class Usage Examples

Public Methods

Method Description
DeriveParameters ( NpgsqlCommand command ) : void

This method is reponsible to derive the command parameter list with values obtained from function definition. It clears the Parameters collection of command. Also, if there is any parameter type which is not supported by Npgsql, an InvalidOperationException will be thrown. Parameters name will be parameter1, parameter2, ...

GetDeleteCommand ( ) : NpgsqlCommand

Gets the automatically generated System.Data.Common.DbCommand object required to perform deletions at the data source.

GetDeleteCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand

Gets the automatically generated NpgsqlCommand object required to perform deletions at the data source, optionally using columns for parameter names.

GetInsertCommand ( ) : NpgsqlCommand

Gets the automatically generated NpgsqlCommand object required to perform insertions at the data source.

GetInsertCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand

Gets the automatically generated NpgsqlCommand object required to perform insertions at the data source, optionally using columns for parameter names.

GetUpdateCommand ( ) : NpgsqlCommand

Gets the automatically generated System.Data.Common.DbCommand object required to perform updates at the data source.

GetUpdateCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand

Gets the automatically generated NpgsqlCommand object required to perform updates at the data source, optionally using columns for parameter names.

NpgsqlCommandBuilder ( ) : System

Initializes a new instance of the NpgsqlCommandBuilder class.

NpgsqlCommandBuilder ( Npgsql.NpgsqlDataAdapter adapter ) : System

Initializes a new instance of the NpgsqlCommandBuilder class.

QuoteIdentifier ( string unquotedIdentifier ) : string

Given an unquoted identifier in the correct catalog case, returns the correct quoted form of that identifier, including properly escaping any embedded quotes in the identifier.

UnquoteIdentifier ( string quotedIdentifier ) : string

Given a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.

Protected Methods

Method Description
ApplyParameterInfo ( DbParameter p, DataRow row, System statementType, bool whereClause ) : void

Applies the parameter information.

GetParameterName ( int parameterOrdinal ) : string

Returns the name of the specified parameter in the format of @p#.

GetParameterName ( string parameterName ) : string

Returns the full parameter name, given the partial parameter name.

GetParameterPlaceholder ( int parameterOrdinal ) : string

Returns the placeholder for the parameter in the associated SQL statement.

SetRowUpdatingHandler ( DbDataAdapter adapter ) : void

Registers the T:NpgsqlCommandBuilder to handle the E:NpgsqlDataAdapter.RowUpdating event for a T:NpgsqlDataAdapter.

Private Methods

Method Description
DoDeriveParameters ( NpgsqlCommand command ) : void
RowUpdatingHandler ( object sender, Npgsql.NpgsqlRowUpdatingEventArgs e ) : void

Adds an event handler for the NpgsqlDataAdapter.RowUpdating event.

Method Details

ApplyParameterInfo() protected method

Applies the parameter information.
protected ApplyParameterInfo ( DbParameter p, DataRow row, System statementType, bool whereClause ) : void
p System.Data.Common.DbParameter The parameter.
row System.Data.DataRow The row.
statementType System Type of the statement.
whereClause bool if set to true [where clause].
return void

DeriveParameters() public static method

This method is reponsible to derive the command parameter list with values obtained from function definition. It clears the Parameters collection of command. Also, if there is any parameter type which is not supported by Npgsql, an InvalidOperationException will be thrown. Parameters name will be parameter1, parameter2, ...
public static DeriveParameters ( NpgsqlCommand command ) : void
command NpgsqlCommand NpgsqlCommand whose function parameters will be obtained.
return void

GetDeleteCommand() public method

Gets the automatically generated System.Data.Common.DbCommand object required to perform deletions at the data source.
public GetDeleteCommand ( ) : NpgsqlCommand
return NpgsqlCommand

GetDeleteCommand() public method

Gets the automatically generated NpgsqlCommand object required to perform deletions at the data source, optionally using columns for parameter names.
public GetDeleteCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand
useColumnsForParameterNames bool /// If true, generate parameter names matching column names, if possible. /// If false, generate @p1, @p2, and so on. ///
return NpgsqlCommand

GetInsertCommand() public method

Gets the automatically generated NpgsqlCommand object required to perform insertions at the data source.
public GetInsertCommand ( ) : NpgsqlCommand
return NpgsqlCommand

GetInsertCommand() public method

Gets the automatically generated NpgsqlCommand object required to perform insertions at the data source, optionally using columns for parameter names.
public GetInsertCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand
useColumnsForParameterNames bool /// If true, generate parameter names matching column names, if possible. /// If false, generate @p1, @p2, and so on. ///
return NpgsqlCommand

GetParameterName() protected method

Returns the name of the specified parameter in the format of @p#.
protected GetParameterName ( int parameterOrdinal ) : string
parameterOrdinal int The number to be included as part of the parameter's name..
return string

GetParameterName() protected method

Returns the full parameter name, given the partial parameter name.
protected GetParameterName ( string parameterName ) : string
parameterName string The partial name of the parameter.
return string

GetParameterPlaceholder() protected method

Returns the placeholder for the parameter in the associated SQL statement.
protected GetParameterPlaceholder ( int parameterOrdinal ) : string
parameterOrdinal int The number to be included as part of the parameter's name.
return string

GetUpdateCommand() public method

Gets the automatically generated System.Data.Common.DbCommand object required to perform updates at the data source.
public GetUpdateCommand ( ) : NpgsqlCommand
return NpgsqlCommand

GetUpdateCommand() public method

Gets the automatically generated NpgsqlCommand object required to perform updates at the data source, optionally using columns for parameter names.
public GetUpdateCommand ( bool useColumnsForParameterNames ) : NpgsqlCommand
useColumnsForParameterNames bool /// If true, generate parameter names matching column names, if possible. /// If false, generate @p1, @p2, and so on. ///
return NpgsqlCommand

NpgsqlCommandBuilder() public method

Initializes a new instance of the NpgsqlCommandBuilder class.
public NpgsqlCommandBuilder ( ) : System
return System

NpgsqlCommandBuilder() public method

Initializes a new instance of the NpgsqlCommandBuilder class.
public NpgsqlCommandBuilder ( Npgsql.NpgsqlDataAdapter adapter ) : System
adapter Npgsql.NpgsqlDataAdapter The adapter.
return System

QuoteIdentifier() public method

Given an unquoted identifier in the correct catalog case, returns the correct quoted form of that identifier, including properly escaping any embedded quotes in the identifier.
Unquoted identifier parameter cannot be null
public QuoteIdentifier ( string unquotedIdentifier ) : string
unquotedIdentifier string The original unquoted identifier.
return string

SetRowUpdatingHandler() protected method

Registers the T:NpgsqlCommandBuilder to handle the E:NpgsqlDataAdapter.RowUpdating event for a T:NpgsqlDataAdapter.
protected SetRowUpdatingHandler ( DbDataAdapter adapter ) : void
adapter System.Data.Common.DbDataAdapter The to be used for the update.
return void

UnquoteIdentifier() public method

Given a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.
Quoted identifier parameter cannot be null
public UnquoteIdentifier ( string quotedIdentifier ) : string
quotedIdentifier string The identifier that will have its embedded quotes removed.
return string