# Class NpgsqlModificationCommandBatch

Namespace
  Npgsql.EntityFrameworkCore.PostgreSQL.Update.Internal

Assembly
  Npgsql.EntityFrameworkCore.PostgreSQL.dll

The Npgsql-specific implementation for ModificationCommandBatch.

    public class NpgsqlModificationCommandBatch : ReaderModificationCommandBatch

Inheritance
  object
  ModificationCommandBatch
  ReaderModificationCommandBatch
  NpgsqlModificationCommandBatch

Inherited Members
  ReaderModificationCommandBatch.TryAddCommand(IReadOnlyModificationCommand)
  ReaderModificationCommandBatch.RollbackLastCommand(IReadOnlyModificationCommand)
  ReaderModificationCommandBatch.SetRequiresTransaction(bool)
  ReaderModificationCommandBatch.IsValid()
  ReaderModificationCommandBatch.AddCommand(IReadOnlyModificationCommand)
  ReaderModificationCommandBatch.Complete(bool)
  ReaderModificationCommandBatch.AddParameters(IReadOnlyModificationCommand)
  ReaderModificationCommandBatch.Execute(IRelationalConnection)
  ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection, CancellationToken)
  ReaderModificationCommandBatch.Dependencies
  ReaderModificationCommandBatch.UpdateSqlGenerator
  ReaderModificationCommandBatch.RelationalCommandBuilder
  ReaderModificationCommandBatch.SqlBuilder
  ReaderModificationCommandBatch.ParameterValues
  ReaderModificationCommandBatch.ModificationCommands
  ReaderModificationCommandBatch.ResultSetMappings
  ReaderModificationCommandBatch.StoreCommand
  ReaderModificationCommandBatch.IsCommandTextEmpty
  ReaderModificationCommandBatch.RequiresTransaction
  ReaderModificationCommandBatch.AreMoreBatchesExpected
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Remarks

The usual ModificationCommandBatch implementation is AffectedCountModificationCommandBatch, which selects the number of rows modified via a SQL query. PostgreSQL actually has no way of selecting the modified row count. SQL defines GET DIAGNOSTICS which should provide this, but in PostgreSQL it's only available in PL/pgSQL. See http://www.postgresql.org/docs/9.4/static/unsupported-features-sql-standard.html, identifier F121-01. Instead, the affected row count can be accessed in the PostgreSQL protocol itself, which seems cleaner and more efficient anyway (no additional query).

## Constructors

### NpgsqlModificationCommandBatch(ModificationCommandBatchFactoryDependencies, int)

Constructs an instance of the NpgsqlModificationCommandBatch class.

    public NpgsqlModificationCommandBatch(ModificationCommandBatchFactoryDependencies dependencies, int maxBatchSize)

#### Parameters

`dependencies` ModificationCommandBatchFactoryDependencies
`maxBatchSize` int

## Properties

### MaxBatchSize

The maximum number of ModificationCommand instances that can be added to a single batch; defaults to 1000.

    protected override int MaxBatchSize { get; }

#### Property Value

int

## Methods

### AddParameter(IColumnModification)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

    protected override void AddParameter(IColumnModification columnModification)

#### Parameters

`columnModification` IColumnModification

### Consume(RelationalDataReader)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

    protected override void Consume(RelationalDataReader reader)

#### Parameters

`reader` RelationalDataReader

### ConsumeAsync(RelationalDataReader, CancellationToken)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

    protected override Task ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken = default)

#### Parameters

`reader` RelationalDataReader
`cancellationToken` CancellationToken

#### Returns

Task

### ThrowAggregateUpdateConcurrencyException(RelationalDataReader, int, int, int)

Throws an exception indicating the command affected an unexpected number of rows.

    protected virtual void ThrowAggregateUpdateConcurrencyException(RelationalDataReader reader, int commandIndex, int expectedRowsAffected, int rowsAffected)

#### Parameters

`reader` RelationalDataReader

  The data reader.

`commandIndex` int

  The ordinal of the command.

`expectedRowsAffected` int

  The expected number of rows affected.

`rowsAffected` int

  The actual number of rows affected.

### ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader, int, int, int, CancellationToken)

Throws an exception indicating the command affected an unexpected number of rows.

    protected virtual Task ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, int commandIndex, int expectedRowsAffected, int rowsAffected, CancellationToken cancellationToken)

#### Parameters

`reader` RelationalDataReader

  The data reader.

`commandIndex` int

  The ordinal of the command.

`expectedRowsAffected` int

  The expected number of rows affected.

`rowsAffected` int

  The actual number of rows affected.

`cancellationToken` CancellationToken

  A CancellationToken to observe while waiting for the task to complete.

#### Returns

Task

  A task that represents the asynchronous operation.

#### Exceptions

OperationCanceledException

  If the CancellationToken is canceled.