Class ReaderModificationCommandBatch
- Namespace
- Microsoft.EntityFrameworkCore.Update
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
A base class for ModificationCommandBatch implementations that make use of a data reader.
This type is typically used by database providers; it is generally not used in application code.
public abstract class ReaderModificationCommandBatch : ModificationCommandBatch
- Inheritance
-
ReaderModificationCommandBatch
- Derived
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Constructors
ReaderModificationCommandBatch(ModificationCommandBatchFactoryDependencies, int?)
Creates a new ReaderModificationCommandBatch instance.
protected ReaderModificationCommandBatch(ModificationCommandBatchFactoryDependencies dependencies, int? maxBatchSize = null)
Parameters
dependencies
ModificationCommandBatchFactoryDependenciesService dependencies.
maxBatchSize
int?The maximum batch size. Defaults to 1000.
Properties
AreMoreBatchesExpected
public override bool AreMoreBatchesExpected { get; }
Property Value
Dependencies
Relational provider-specific dependencies for this service.
protected virtual ModificationCommandBatchFactoryDependencies Dependencies { get; }
Property Value
IsCommandTextEmpty
Whether any SQL has already been added to the batch command text.
protected virtual bool IsCommandTextEmpty { get; }
Property Value
MaxBatchSize
The maximum number of ModificationCommand instances that can be added to a single batch.
protected virtual int MaxBatchSize { get; }
Property Value
ModificationCommands
The list of conceptual insert/update/delete ModificationCommandss in the batch.
public override IReadOnlyList<IReadOnlyModificationCommand> ModificationCommands { get; }
Property Value
ParameterValues
Gets the parameter values for the commands in the batch.
protected virtual Dictionary<string, object?> ParameterValues { get; }
Property Value
RelationalCommandBuilder
Gets the relational command builder for the commands in the batch.
protected virtual IRelationalCommandBuilder RelationalCommandBuilder { get; }
Property Value
RequiresTransaction
public override bool RequiresTransaction { get; }
Property Value
ResultSetMappings
The ResultSetMappings for each command in ModificationCommands.
protected virtual IList<ResultSetMapping> ResultSetMappings { get; }
Property Value
SqlBuilder
Gets the command text builder for the commands in the batch.
protected virtual StringBuilder SqlBuilder { get; }
Property Value
StoreCommand
The store command generated from this batch when Complete(bool) is called.
protected virtual RawSqlCommand? StoreCommand { get; set; }
Property Value
UpdateSqlGenerator
The update SQL generator.
protected virtual IUpdateSqlGenerator UpdateSqlGenerator { get; }
Property Value
Methods
AddCommand(IReadOnlyModificationCommand)
Adds Updates the command text for the command at the given position in the ModificationCommands list.
protected virtual void AddCommand(IReadOnlyModificationCommand modificationCommand)
Parameters
modificationCommand
IReadOnlyModificationCommandThe command to add.
AddParameter(IColumnModification)
Adds a parameter for the given columnModification
to the relational command being built for this batch.
protected virtual void AddParameter(IColumnModification columnModification)
Parameters
columnModification
IColumnModificationThe column modification for which to add parameters.
AddParameters(IReadOnlyModificationCommand)
Adds parameters for all column modifications in the given modificationCommand
to the relational command
being built for this batch.
protected virtual void AddParameters(IReadOnlyModificationCommand modificationCommand)
Parameters
modificationCommand
IReadOnlyModificationCommandThe modification command for which to add parameters.
Complete(bool)
public override void Complete(bool moreBatchesExpected)
Parameters
moreBatchesExpected
bool
Consume(RelationalDataReader)
Consumes the data reader created by Execute(IRelationalConnection).
protected abstract void Consume(RelationalDataReader reader)
Parameters
reader
RelationalDataReaderThe data reader.
ConsumeAsync(RelationalDataReader, CancellationToken)
Consumes the data reader created by ExecuteAsync(IRelationalConnection, CancellationToken).
protected abstract Task ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken = default)
Parameters
reader
RelationalDataReaderThe data reader.
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.
Execute(IRelationalConnection)
Executes the command generated by this batch against a database using the given connection.
public override void Execute(IRelationalConnection connection)
Parameters
connection
IRelationalConnectionThe connection to the database to update.
ExecuteAsync(IRelationalConnection, CancellationToken)
Executes the command generated by this batch against a database using the given connection.
public override Task ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken = default)
Parameters
connection
IRelationalConnectionThe connection to the database to update.
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.
IsValid()
Checks whether the command text is valid.
protected virtual bool IsValid()
Returns
RollbackLastCommand(IReadOnlyModificationCommand)
Rolls back the last command added. Used when adding a command caused the batch to become invalid (e.g. CommandText too long).
protected virtual void RollbackLastCommand(IReadOnlyModificationCommand modificationCommand)
Parameters
modificationCommand
IReadOnlyModificationCommand
SetRequiresTransaction(bool)
Sets whether the batch requires a transaction in order to execute correctly.
protected virtual void SetRequiresTransaction(bool requiresTransaction)
Parameters
requiresTransaction
boolWhether the batch requires a transaction in order to execute correctly.
TryAddCommand(IReadOnlyModificationCommand)
public override bool TryAddCommand(IReadOnlyModificationCommand modificationCommand)
Parameters
modificationCommand
IReadOnlyModificationCommand