Class NpgsqlModificationCommandBatch
- Namespace
- Npgsql.EntityFrameworkCore.PostgreSQL.Update.Internal
- Assembly
- Npgsql.EntityFrameworkCore.PostgreSQL.dll
The Npgsql-specific implementation for ModificationCommandBatch.
public class NpgsqlModificationCommandBatch : ReaderModificationCommandBatch
- Inheritance
-
NpgsqlModificationCommandBatch
- Inherited Members
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
ModificationCommandBatchFactoryDependenciesmaxBatchSize
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
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
RelationalDataReadercancellationToken
CancellationToken
Returns
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
RelationalDataReaderThe data reader.
commandIndex
intThe ordinal of the command.
expectedRowsAffected
intThe expected number of rows affected.
rowsAffected
intThe 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
RelationalDataReaderThe data reader.
commandIndex
intThe ordinal of the command.
expectedRowsAffected
intThe expected number of rows affected.
rowsAffected
intThe actual number of rows affected.
cancellationToken
CancellationTokenA 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.