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
Constructors
ReaderModificationCommandBatch(ModificationCommandBatchFactoryDependencies)
Creates a new ReaderModificationCommandBatch instance.
protected ReaderModificationCommandBatch(ModificationCommandBatchFactoryDependencies dependencies)
Parameters
dependencies
ModificationCommandBatchFactoryDependenciesService dependencies.
Properties
CachedCommandText
Gets or sets the cached command text for the commands in the batch.
protected virtual StringBuilder CachedCommandText { get; set; }
Property Value
CommandResultSet
The ResultSetMappings for each command in ModificationCommands.
protected virtual IList<ResultSetMapping> CommandResultSet { get; }
Property Value
Dependencies
Service dependencies.
public virtual ModificationCommandBatchFactoryDependencies Dependencies { get; }
Property Value
LastCachedCommandIndex
The ordinal of the last command for which command text was built.
protected virtual int LastCachedCommandIndex { get; set; }
Property Value
ModificationCommands
The list of conceptual insert/update/delete ModificationCommandss in the batch.
public override IReadOnlyList<ModificationCommand> ModificationCommands { get; }
Property Value
UpdateSqlGenerator
The update SQL generator.
protected virtual IUpdateSqlGenerator UpdateSqlGenerator { get; }
Property Value
Methods
AddCommand(ModificationCommand)
Adds the given insert/update/delete ModificationCommands to the batch.
public override bool AddCommand(ModificationCommand modificationCommand)
Parameters
modificationCommand
ModificationCommandThe command to add.
Returns
- bool
true if the command was successfully added; false if there was no room in the current batch to add the command and it must instead be added to a new batch.
CanAddCommand(ModificationCommand)
Checks whether or not a new command can be added to the batch.
protected abstract bool CanAddCommand(ModificationCommand modificationCommand)
Parameters
modificationCommand
ModificationCommandThe command to potentially add.
Returns
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.
CreateStoreCommand()
Generates a RawSqlCommand for the batch.
protected virtual RawSqlCommand CreateStoreCommand()
Returns
- RawSqlCommand
The command.
CreateValueBufferFactory(IReadOnlyList<ColumnModification>)
Creates the IRelationalValueBufferFactory that will be used for creating a Microsoft.EntityFrameworkCore.Storage.ValueBuffer to consume the data reader.
protected virtual IRelationalValueBufferFactory CreateValueBufferFactory(IReadOnlyList<ColumnModification> columnModifications)
Parameters
columnModifications
IReadOnlyList<ColumnModification>The list of ColumnModifications for all the columns being modified such that a ValueBuffer with appropriate slots can be created.
Returns
- IRelationalValueBufferFactory
The factory.
Execute(IRelationalConnection)
Executes the command generated by CreateStoreCommand() 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 CreateStoreCommand() 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.
GetCommandText()
Gets the command text for all the commands in the current batch and also caches it on CachedCommandText.
protected virtual string GetCommandText()
Returns
- string
The command text.
GetParameterCount()
Gets the total number of parameters needed for the batch.
protected virtual int GetParameterCount()
Returns
- int
The total parameter count.
IsCommandTextValid()
Checks whether or not the command text is valid.
protected abstract bool IsCommandTextValid()
Returns
ResetCommandText()
Resets the builder to start building a new batch.
protected virtual void ResetCommandText()
UpdateCachedCommandText(int)
Updates the command text for the command at the given position in the ModificationCommands list.
protected virtual void UpdateCachedCommandText(int commandPosition)
Parameters
commandPosition
intThe position of the command to generate command text for.