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
UpdateSqlGeneratorDependenciesParameter object containing dependencies for this service.
Properties
Dependencies
Parameter object containing service dependencies.
protected virtual UpdateSqlGeneratorDependencies Dependencies { get; }
Property Value
SqlGenerationHelper
Helpers for generating update SQL.
protected virtual ISqlGenerationHelper SqlGenerationHelper { get; }
Property Value
Methods
AppendBatchHeader(StringBuilder)
Appends SQL text that defines the start of a batch.
public virtual void AppendBatchHeader(StringBuilder commandStringBuilder)
Parameters
commandStringBuilder
StringBuilderThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
command
ModificationCommandThe command that represents the delete operation.
commandPosition
intThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
columnModification
ColumnModificationThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
command
ModificationCommandThe command that represents the delete operation.
commandPosition
intThe 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
StringBuilderThe builder to which the SQL fragment should be appended.
name
stringThe name of the sequence.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
expectedRowsAffected
intThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
intThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe table schema, or null to use the default schema.
commandPosition
intThe 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
StringBuilderThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe builder to which the SQL should be appended.
command
ModificationCommandThe command that represents the delete operation.
commandPosition
intThe ordinal of this command in the batch.
Returns
- ResultSetMapping
The ResultSetMapping for the command.
AppendValues(StringBuilder, string, string, IReadOnlyList<ColumnModification>)
Appends values after a AppendValuesHeader(StringBuilder, IReadOnlyList<ColumnModification>) call.
protected virtual void AppendValues(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<ColumnModification> operations)
Parameters
commandStringBuilder
StringBuilderThe builder to which the SQL should be appended.
name
stringThe name of the table.
schema
stringThe 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
StringBuilderThe 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
StringBuilderThe 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
StringBuilderThe 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
StringBuilderThe builder to which the SQL should be appended.
columnModification
ColumnModificationThe column for which the condition is being generated.
useOriginalValue
boolIf 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
stringThe name of the sequence.
schema
stringThe schema that contains the sequence, or null to use the default schema.
Returns
- string
The SQL.