# Class NpgsqlCommandBuilder

Namespace
  Npgsql

Assembly
  Npgsql.dll

This class creates database commands for automatic insert, update and delete operations.

    public sealed class NpgsqlCommandBuilder : DbCommandBuilder, IComponent, IDisposable

Inheritance
  object
  MarshalByRefObject
  Component
  DbCommandBuilder
  NpgsqlCommandBuilder

Implements
  IComponent
  IDisposable

Inherited Members
  DbCommandBuilder.RefreshSchema()
  DbCommandBuilder.CatalogLocation
  DbCommandBuilder.CatalogSeparator
  DbCommandBuilder.ConflictOption
  DbCommandBuilder.DataAdapter
  DbCommandBuilder.SchemaSeparator
  DbCommandBuilder.SetAllValues
  Component.Dispose()
  Component.ToString()
  Component.Container
  Component.Site
  Component.Disposed
  MarshalByRefObject.GetLifetimeService()
  MarshalByRefObject.InitializeLifetimeService()
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.ReferenceEquals(object, object)

## Constructors

### NpgsqlCommandBuilder()

Initializes a new instance of the NpgsqlCommandBuilder class.

    public NpgsqlCommandBuilder()

### NpgsqlCommandBuilder(NpgsqlDataAdapter?)

Initializes a new instance of the NpgsqlCommandBuilder class.

    public NpgsqlCommandBuilder(NpgsqlDataAdapter? adapter)

#### Parameters

`adapter` NpgsqlDataAdapter

  The adapter.

## Properties

### QuotePrefix

Gets or sets the beginning character or characters to use when specifying database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.

    public override string QuotePrefix { get; set; }

#### Property Value

string

  The beginning character or characters to use. The default is an empty string.

### QuoteSuffix

Gets or sets the ending character or characters to use when specifying database objects (for example, tables or columns) whose names contain characters such as spaces or reserved tokens.

    public override string QuoteSuffix { get; set; }

#### Property Value

string

  The ending character or characters to use. The default is an empty string.

## Methods

### ApplyParameterInfo(DbParameter, DataRow, StatementType, bool)

Applies the parameter information.

    protected override void ApplyParameterInfo(DbParameter p, DataRow row, StatementType statementType, bool whereClause)

#### Parameters

`p` DbParameter

  The parameter.

`row` DataRow

  The row.

`statementType` StatementType

  Type of the statement.

`whereClause` bool

  If set to true [where clause].

### DeriveParameters(NpgsqlCommand)

This method is responsible 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, ... for CommandType.StoredProcedure and named after the placeholder for CommandType.Text

    public static void DeriveParameters(NpgsqlCommand command)

#### Parameters

`command` NpgsqlCommand

  NpgsqlCommand whose function parameters will be obtained.

### GetDeleteCommand()

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

    public NpgsqlCommand GetDeleteCommand()

#### Returns

NpgsqlCommand

  The automatically generated System.Data.Common.DbCommand object required to perform deletions.

### GetDeleteCommand(bool)

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

    public NpgsqlCommand GetDeleteCommand(bool useColumnsForParameterNames)

#### Parameters

`useColumnsForParameterNames` bool

  If true, generate parameter names matching column names, if possible. If false, generate @p1, @p2, and so on.

#### Returns

NpgsqlCommand

  The automatically generated NpgsqlCommand object required to perform deletions.

### GetInsertCommand()

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

    public NpgsqlCommand GetInsertCommand()

#### Returns

NpgsqlCommand

  The automatically generated NpgsqlCommand object required to perform insertions.

### GetInsertCommand(bool)

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

    public NpgsqlCommand GetInsertCommand(bool useColumnsForParameterNames)

#### Parameters

`useColumnsForParameterNames` bool

  If true, generate parameter names matching column names, if possible. If false, generate `@p1`, `@p2`, and so on.

#### Returns

NpgsqlCommand

  The automatically generated NpgsqlCommand object required to perform insertions.

### GetParameterName(int)

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

    protected override string GetParameterName(int parameterOrdinal)

#### Parameters

`parameterOrdinal` int

  The number to be included as part of the parameter's name..

#### Returns

string

  The name of the parameter with the specified number appended as part of the parameter name.

### GetParameterName(string)

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

    protected override string GetParameterName(string parameterName)

#### Parameters

`parameterName` string

  The partial name of the parameter.

#### Returns

string

  The full parameter name corresponding to the partial parameter name requested.

### GetParameterPlaceholder(int)

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

    protected override string GetParameterPlaceholder(int parameterOrdinal)

#### Parameters

`parameterOrdinal` int

  The number to be included as part of the parameter's name.

#### Returns

string

  The name of the parameter with the specified number appended.

### GetUpdateCommand()

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

    public NpgsqlCommand GetUpdateCommand()

#### Returns

NpgsqlCommand

  The automatically generated System.Data.Common.DbCommand object required to perform updates.

### GetUpdateCommand(bool)

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

    public NpgsqlCommand GetUpdateCommand(bool useColumnsForParameterNames)

#### Parameters

`useColumnsForParameterNames` bool

  If true, generate parameter names matching column names, if possible. If false, generate `@p1`, `@p2`, and so on.

#### Returns

NpgsqlCommand

  The automatically generated NpgsqlCommand object required to perform updates.

### QuoteIdentifier(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.

    public override string QuoteIdentifier(string unquotedIdentifier)

#### Parameters

`unquotedIdentifier` string

  The original unquoted identifier.

#### Returns

string

  The quoted version of the identifier. Embedded quotes within the identifier are properly escaped.

#### Exceptions

ArgumentNullException

  Unquoted identifier parameter cannot be null

### SetRowUpdatingHandler(DbDataAdapter)

Registers the NpgsqlCommandBuilder to handle the RowUpdating event for a NpgsqlDataAdapter.

    protected override void SetRowUpdatingHandler(DbDataAdapter adapter)

#### Parameters

`adapter` DbDataAdapter

  The DbDataAdapter to be used for the update.

### UnquoteIdentifier(string)

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

    public override string UnquoteIdentifier(string quotedIdentifier)

#### Parameters

`quotedIdentifier` string

  The identifier that will have its embedded quotes removed.

#### Returns

string

  The unquoted identifier, with embedded quotes properly un-escaped.

#### Exceptions

ArgumentNullException

  Quoted identifier parameter cannot be null