Table of Contents

Class ModificationCommandBatch

Namespace
Microsoft.EntityFrameworkCore.Update
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

A base class for a collection of ModificationCommands that can be executed as a batch.

This type is typically used by database providers; it is generally not used in application code.

public abstract class ModificationCommandBatch
Inheritance
ModificationCommandBatch
Derived
Inherited Members

Remarks

See Implementation of database providers and extensions for more information and examples.

Constructors

ModificationCommandBatch()

protected ModificationCommandBatch()

Properties

AreMoreBatchesExpected

Indicates whether more batches are expected after this one.

public abstract bool AreMoreBatchesExpected { get; }

Property Value

bool

ModificationCommands

The list of conceptual insert/update/delete ModificationCommandss in the batch.

public abstract IReadOnlyList<IReadOnlyModificationCommand> ModificationCommands { get; }

Property Value

IReadOnlyList<IReadOnlyModificationCommand>

RequiresTransaction

Indicates whether the batch requires a transaction in order to execute correctly.

public abstract bool RequiresTransaction { get; }

Property Value

bool

Methods

Complete(bool)

Indicates that no more commands will be added to this batch, and prepares it for execution.

public abstract void Complete(bool moreBatchesExpected)

Parameters

moreBatchesExpected bool

Execute(IRelationalConnection)

Sends insert/update/delete commands to the database.

public abstract void Execute(IRelationalConnection connection)

Parameters

connection IRelationalConnection

The database connection to use.

ExecuteAsync(IRelationalConnection, CancellationToken)

Sends insert/update/delete commands to the database.

public abstract Task ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken = default)

Parameters

connection IRelationalConnection

The database connection to use.

cancellationToken CancellationToken

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

Returns

Task

A task that represents the asynchronous save operation.

Exceptions

OperationCanceledException

If the CancellationToken is canceled.

TryAddCommand(IReadOnlyModificationCommand)

Attempts to adds the given insert/update/delete modificationCommand to the batch.

public abstract bool TryAddCommand(IReadOnlyModificationCommand modificationCommand)

Parameters

modificationCommand IReadOnlyModificationCommand

The 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.