Class RelationalSqlGenerationHelper
- Namespace
- Microsoft.EntityFrameworkCore.Storage
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
Provides services to help with generation of SQL commands.
This type is typically used by database providers (and other extensions). It is generally not used in application code.
public class RelationalSqlGenerationHelper : ISqlGenerationHelper
- Inheritance
-
RelationalSqlGenerationHelper
- Implements
- Inherited Members
Remarks
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.
See Implementation of database providers and extensions for more information and examples.
Constructors
RelationalSqlGenerationHelper(RelationalSqlGenerationHelperDependencies)
Initializes a new instance of the this class.
public RelationalSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependencies)
Parameters
dependencies
RelationalSqlGenerationHelperDependenciesParameter object containing dependencies for this service.
Properties
BatchTerminator
The terminator to be used for batches of SQL statements.
public virtual string BatchTerminator { get; }
Property Value
CommitTransactionStatement
public virtual string CommitTransactionStatement { get; }
Property Value
Dependencies
Relational provider-specific dependencies for this service.
protected virtual RelationalSqlGenerationHelperDependencies Dependencies { get; }
Property Value
SingleLineCommentToken
The default single-line comment prefix.
public virtual string SingleLineCommentToken { get; }
Property Value
StartTransactionStatement
public virtual string StartTransactionStatement { get; }
Property Value
StatementTerminator
The terminator to be used for SQL statements.
public virtual string StatementTerminator { get; }
Property Value
Methods
DelimitIdentifier(string)
Generates the delimited SQL representation of an identifier (column name, table name, etc.).
public virtual string DelimitIdentifier(string identifier)
Parameters
identifier
stringThe identifier to delimit.
Returns
- string
The generated string.
DelimitIdentifier(string, string?)
Generates the delimited SQL representation of an identifier (column name, table name, etc.).
public virtual string DelimitIdentifier(string name, string? schema)
Parameters
Returns
- string
The generated string.
DelimitIdentifier(StringBuilder, string)
Writes the delimited SQL representation of an identifier (column name, table name, etc.).
public virtual void DelimitIdentifier(StringBuilder builder, string identifier)
Parameters
builder
StringBuilderThe StringBuilder to write generated string to.
identifier
stringThe identifier to delimit.
DelimitIdentifier(StringBuilder, string, string?)
Writes the delimited SQL representation of an identifier (column name, table name, etc.).
public virtual void DelimitIdentifier(StringBuilder builder, string name, string? schema)
Parameters
builder
StringBuilderThe StringBuilder to write generated string to.
name
stringThe identifier to delimit.
schema
stringThe schema of the identifier.
EscapeIdentifier(string)
Generates the escaped SQL representation of an identifier (column name, table name, etc.).
public virtual string EscapeIdentifier(string identifier)
Parameters
identifier
stringThe identifier to be escaped.
Returns
- string
The generated string.
EscapeIdentifier(StringBuilder, string)
Writes the escaped SQL representation of an identifier (column name, table name, etc.).
public virtual void EscapeIdentifier(StringBuilder builder, string identifier)
Parameters
builder
StringBuilderThe StringBuilder to write generated string to.
identifier
stringThe identifier to be escaped.
GenerateComment(string)
Generates a SQL comment.
public virtual string GenerateComment(string text)
Parameters
text
stringThe comment text.
Returns
- string
The generated SQL.
GenerateCreateSavepointStatement(string)
Generates an SQL statement which creates a savepoint with the given name.
public virtual string GenerateCreateSavepointStatement(string name)
Parameters
name
stringThe name of the savepoint to be created.
Returns
- string
An SQL string to create the savepoint.
GenerateParameterName(string)
Generates a valid parameter name for the given candidate name.
public virtual string GenerateParameterName(string name)
Parameters
name
stringThe candidate name for the parameter.
Returns
- string
A valid name based on the candidate name.
GenerateParameterName(StringBuilder, string)
Writes a valid parameter name for the given candidate name.
public virtual void GenerateParameterName(StringBuilder builder, string name)
Parameters
builder
StringBuilderThe StringBuilder to write generated string to.
name
stringThe candidate name for the parameter.
GenerateParameterNamePlaceholder(string)
Generates a valid parameter placeholder name for the given candidate name.
public virtual string GenerateParameterNamePlaceholder(string name)
Parameters
name
stringThe candidate name for the parameter placeholder.
Returns
- string
A valid name based on the candidate name.
GenerateParameterNamePlaceholder(StringBuilder, string)
Writes a valid parameter placeholder name for the given candidate name.
public virtual void GenerateParameterNamePlaceholder(StringBuilder builder, string name)
Parameters
builder
StringBuilderThe StringBuilder to write generated string to.
name
stringThe candidate name for the parameter placeholder.
GenerateReleaseSavepointStatement(string)
Generates an SQL statement which releases a savepoint with the given name.
public virtual string GenerateReleaseSavepointStatement(string name)
Parameters
name
stringThe name of the savepoint to be released.
Returns
- string
An SQL string to release the savepoint.
GenerateRollbackToSavepointStatement(string)
Generates an SQL statement which rolls back to a savepoint with the given name.
public virtual string GenerateRollbackToSavepointStatement(string name)
Parameters
name
stringThe name of the savepoint to be rolled back to.
Returns
- string
An SQL string to roll back the savepoint.