Table of Contents

Class UpdateSqlGenerator

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

A base class for the IUpdateSqlGenerator service that is typically inherited from by database providers.

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

The service lifetime is Singleton. This means a single instance is used by many Microsoft.EntityFrameworkCore.DbContext instances. The implementation must be thread-safe. This service cannot depend on services registered as Scoped.

public abstract class UpdateSqlGenerator : IUpdateSqlGenerator
Inheritance
UpdateSqlGenerator
Implements
Inherited Members

Constructors

UpdateSqlGenerator(UpdateSqlGeneratorDependencies)

Initializes a new instance of the this class.

protected UpdateSqlGenerator(UpdateSqlGeneratorDependencies dependencies)

Parameters

dependencies UpdateSqlGeneratorDependencies

Parameter object containing dependencies for this service.

Properties

Dependencies

Parameter object containing service dependencies.

protected virtual UpdateSqlGeneratorDependencies Dependencies { get; }

Property Value

UpdateSqlGeneratorDependencies

SqlGenerationHelper

Helpers for generating update SQL.

protected virtual ISqlGenerationHelper SqlGenerationHelper { get; }

Property Value

ISqlGenerationHelper

Methods

AppendBatchHeader(StringBuilder)

Appends SQL text that defines the start of a batch.

public virtual void AppendBatchHeader(StringBuilder commandStringBuilder)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

AppendDeleteCommand(StringBuilder, string, string, IReadOnlyList<ColumnModification>)

Appends a SQL command for deleting a row to the commands being built.

protected virtual void AppendDeleteCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> conditionOperations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

conditionOperations IReadOnlyList<ColumnModification>

The operations used to generate the WHERE clause for the delete.

AppendDeleteCommandHeader(StringBuilder, string, string)

Appends a SQL fragment for starting an DELETE.

protected virtual void AppendDeleteCommandHeader(StringBuilder commandStringBuilder, string name, string schema)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

AppendDeleteOperation(StringBuilder, ModificationCommand, int)

Appends a SQL command for deleting a row to the commands being built.

public virtual ResultSetMapping AppendDeleteOperation(StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

command ModificationCommand

The command that represents the delete operation.

commandPosition int

The ordinal of this command in the batch.

Returns

ResultSetMapping

The ResultSetMapping for the command.

AppendFromClause(StringBuilder, string, string)

Appends a SQL fragment for starting an FROM clause.

protected virtual void AppendFromClause(StringBuilder commandStringBuilder, string name, string schema)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

AppendIdentityWhereCondition(StringBuilder, ColumnModification)

Appends a WHERE condition for the identity (i.e. key value) of the given column.

protected abstract void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

columnModification ColumnModification

The column for which the condition is being generated.

AppendInsertCommand(StringBuilder, string, string, IReadOnlyList<ColumnModification>)

Appends a SQL command for inserting a row to the commands being built.

protected virtual void AppendInsertCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> writeOperations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

writeOperations IReadOnlyList<ColumnModification>

The operations for each column.

AppendInsertCommandHeader(StringBuilder, string, string, IReadOnlyList<ColumnModification>)

Appends a SQL fragment for starting an INSERT.

protected virtual void AppendInsertCommandHeader(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

operations IReadOnlyList<ColumnModification>

The operations representing the data to be inserted.

AppendInsertOperation(StringBuilder, ModificationCommand, int)

Appends a SQL command for inserting a row to the commands being built.

public virtual ResultSetMapping AppendInsertOperation(StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

command ModificationCommand

The command that represents the delete operation.

commandPosition int

The ordinal of this command in the batch.

Returns

ResultSetMapping

The ResultSetMapping for the command.

AppendNextSequenceValueOperation(StringBuilder, string, string)

Generates a SQL fragment that will get the next value from the given sequence and appends it to the full command being built by the given StringBuilder.

public virtual void AppendNextSequenceValueOperation(StringBuilder commandStringBuilder, string name, string schema)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL fragment should be appended.

name string

The name of the sequence.

schema string

The schema that contains the sequence, or null to use the default schema.

AppendRowsAffectedWhereCondition(StringBuilder, int)

Appends a WHERE condition checking rows affected.

protected abstract void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

expectedRowsAffected int

The expected number of rows affected.

AppendSelectAffectedCommand(StringBuilder, string, string, IReadOnlyList<ColumnModification>, IReadOnlyList<ColumnModification>, int)

Appends a SQL command for selecting affected data.

protected virtual ResultSetMapping AppendSelectAffectedCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> readOperations, IReadOnlyList<ColumnModification> conditionOperations, int commandPosition)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

readOperations IReadOnlyList<ColumnModification>

The operations representing the data to be read.

conditionOperations IReadOnlyList<ColumnModification>

The operations used to generate the WHERE clause for the select.

commandPosition int

The ordinal of the command for which rows affected it being returned.

Returns

ResultSetMapping

The ResultSetMapping for this command.

AppendSelectAffectedCountCommand(StringBuilder, string, string, int)

Appends a SQL command for selecting the number of rows affected.

protected virtual ResultSetMapping AppendSelectAffectedCountCommand(StringBuilder commandStringBuilder, string name, string schema, int commandPosition)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

commandPosition int

The ordinal of the command for which rows affected it being returned.

Returns

ResultSetMapping

The ResultSetMapping for this command.

AppendSelectCommandHeader(StringBuilder, IReadOnlyList<ColumnModification>)

Appends a SQL fragment for starting an SELECT.

protected virtual void AppendSelectCommandHeader(StringBuilder commandStringBuilder, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

operations IReadOnlyList<ColumnModification>

The operations representing the data to be read.

AppendUpdateCommand(StringBuilder, string, string, IReadOnlyList<ColumnModification>, IReadOnlyList<ColumnModification>)

Appends a SQL command for updating a row to the commands being built.

protected virtual void AppendUpdateCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> writeOperations, IReadOnlyList<ColumnModification> conditionOperations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

writeOperations IReadOnlyList<ColumnModification>

The operations for each column.

conditionOperations IReadOnlyList<ColumnModification>

The operations used to generate the WHERE clause for the update.

AppendUpdateCommandHeader(StringBuilder, string, string, IReadOnlyList<ColumnModification>)

Appends a SQL fragment for starting an UPDATE.

protected virtual void AppendUpdateCommandHeader(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

operations IReadOnlyList<ColumnModification>

The operations representing the data to be updated.

AppendUpdateOperation(StringBuilder, ModificationCommand, int)

Appends a SQL command for updating a row to the commands being built.

public virtual ResultSetMapping AppendUpdateOperation(StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

command ModificationCommand

The command that represents the delete operation.

commandPosition int

The ordinal of this command in the batch.

Returns

ResultSetMapping

The ResultSetMapping for the command.

AppendValues(StringBuilder, string, string, IReadOnlyList<ColumnModification>)

protected virtual void AppendValues(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

name string

The name of the table.

schema string

The table schema, or null to use the default schema.

operations IReadOnlyList<ColumnModification>

The operations for which there are values.

AppendValuesHeader(StringBuilder, IReadOnlyList<ColumnModification>)

Appends a SQL fragment for a VALUES.

protected virtual void AppendValuesHeader(StringBuilder commandStringBuilder, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

operations IReadOnlyList<ColumnModification>

The operations for which there are values.

AppendWhereAffectedClause(StringBuilder, IReadOnlyList<ColumnModification>)

Appends a WHERE clause involving rows affected.

protected virtual void AppendWhereAffectedClause(StringBuilder commandStringBuilder, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

operations IReadOnlyList<ColumnModification>

The operations from which to build the conditions.

AppendWhereClause(StringBuilder, IReadOnlyList<ColumnModification>)

Appends a WHERE clause.

protected virtual void AppendWhereClause(StringBuilder commandStringBuilder, IReadOnlyList<ColumnModification> operations)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

operations IReadOnlyList<ColumnModification>

The operations from which to build the conditions.

AppendWhereCondition(StringBuilder, ColumnModification, bool)

Appends a WHERE condition for the given column.

protected virtual void AppendWhereCondition(StringBuilder commandStringBuilder, ColumnModification columnModification, bool useOriginalValue)

Parameters

commandStringBuilder StringBuilder

The builder to which the SQL should be appended.

columnModification ColumnModification

The column for which the condition is being generated.

useOriginalValue bool

If true, then the original value will be used in the condition, otherwise the current value will be used.

GenerateNextSequenceValueOperation(string, string)

Generates SQL that will obtain the next value in the given sequence.

public virtual string GenerateNextSequenceValueOperation(string name, string schema)

Parameters

name string

The name of the sequence.

schema string

The schema that contains the sequence, or null to use the default schema.

Returns

string

The SQL.