Interface ISqlSyntaxProvider
Defines an SqlSyntaxProvider.
Namespace: Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
Assembly: Umbraco.Infrastructure.dll
Syntax
public interface ISqlSyntaxProvider
Properties
View SourceAddColumn
Gets the SQL syntax statement or template used for adding a column to a table.
Declaration
string AddColumn { get; }
Property Value
| Type | Description |
|---|---|
| string |
AliasRegex
Gets a regex matching aliased fields.
Declaration
Regex AliasRegex { get; }
Property Value
| Type | Description |
|---|---|
| Regex |
Remarks
Matches "(table.column) AS (alias)" where table, column and alias are properly escaped.
AlterColumn
Gets the SQL syntax template or statement used to alter a column in a database table.
Declaration
string AlterColumn { get; }
Property Value
| Type | Description |
|---|---|
| string |
AlterSchema
Gets the SQL syntax template or statement used for altering a database schema.
Declaration
string AlterSchema { get; }
Property Value
| Type | Description |
|---|---|
| string |
ConvertDateToOrderableString
Gets a string representation of a date that preserves chronological order when sorted in SQL queries.
Declaration
string ConvertDateToOrderableString { get; }
Property Value
| Type | Description |
|---|---|
| string |
ConvertDecimalToOrderableString
Gets a string representation of a decimal value that preserves numeric ordering when used in SQL queries.
Declaration
string ConvertDecimalToOrderableString { get; }
Property Value
| Type | Description |
|---|---|
| string |
ConvertIntegerToOrderableString
Gets a string representation of an integer that preserves its numeric order when sorted lexicographically.
Declaration
string ConvertIntegerToOrderableString { get; }
Property Value
| Type | Description |
|---|---|
| string |
ConvertUniqueIdentifierToString
Converts a unique identifier (such as a GUID) to its string representation for use in SQL statements.
Declaration
string ConvertUniqueIdentifierToString { get; }
Property Value
| Type | Description |
|---|---|
| string |
CreateConstraint
Gets the SQL syntax statement used to create a database constraint.
Declaration
string CreateConstraint { get; }
Property Value
| Type | Description |
|---|---|
| string |
CreateIndex
Gets the SQL statement template used for creating an index in the database.
Declaration
string CreateIndex { get; }
Property Value
| Type | Description |
|---|---|
| string |
CreateSchema
Gets the SQL statement used to create a database schema.
Declaration
string CreateSchema { get; }
Property Value
| Type | Description |
|---|---|
| string |
CreateTable
Gets the SQL statement or syntax used to create a table in the database.
Declaration
string CreateTable { get; }
Property Value
| Type | Description |
|---|---|
| string |
DbProvider
Gets the identifier or name of the underlying database provider used by this SQL syntax provider.
Declaration
string DbProvider { get; }
Property Value
| Type | Description |
|---|---|
| string |
DefaultIsolationLevel
Returns the default isolation level for the database
Declaration
IsolationLevel DefaultIsolationLevel { get; }
Property Value
| Type | Description |
|---|---|
| IsolationLevel |
DeleteConstraint
Gets the SQL syntax statement used to delete a database constraint.
Declaration
string DeleteConstraint { get; }
Property Value
| Type | Description |
|---|---|
| string |
DeleteData
Gets the SQL syntax statement or template used for deleting data from a database.
Declaration
string DeleteData { get; }
Property Value
| Type | Description |
|---|---|
| string |
DeleteDefaultConstraint
Gets the SQL syntax statement used to delete a default constraint from a database column.
Declaration
string DeleteDefaultConstraint { get; }
Property Value
| Type | Description |
|---|---|
| string |
DropColumn
Gets the SQL syntax statement used to drop a column from a table.
Declaration
string DropColumn { get; }
Property Value
| Type | Description |
|---|---|
| string |
DropIndex
Gets the SQL syntax template used to generate a statement for dropping an index.
Declaration
string DropIndex { get; }
Property Value
| Type | Description |
|---|---|
| string |
DropSchema
Gets the SQL statement or syntax template used to drop a database schema.
Declaration
string DropSchema { get; }
Property Value
| Type | Description |
|---|---|
| string |
DropTable
Gets the SQL statement template used to drop a table in the database.
Declaration
string DropTable { get; }
Property Value
| Type | Description |
|---|---|
| string |
InsertData
Gets the SQL syntax template used for inserting data into a database table.
Declaration
string InsertData { get; }
Property Value
| Type | Description |
|---|---|
| string |
Length
Gets the SQL syntax expression used to calculate the length of a string in the current SQL dialect.
Declaration
string Length { get; }
Property Value
| Type | Description |
|---|---|
| string |
ProviderName
Gets the name that identifies the SQL syntax provider implementation.
Declaration
string ProviderName { get; }
Property Value
| Type | Description |
|---|---|
| string |
RenameColumn
Gets the SQL syntax statement or template used for renaming a column in a database table.
Declaration
string RenameColumn { get; }
Property Value
| Type | Description |
|---|---|
| string |
RenameTable
Gets the SQL syntax statement used to rename a table in the database.
Declaration
string RenameTable { get; }
Property Value
| Type | Description |
|---|---|
| string |
ScalarMappers
Gets the dictionary of scalar mappers used by the SQL syntax provider. Scalar mappers are responsible for converting database scalar values to .NET types during data retrieval operations. The dictionary maps .NET types to their corresponding IScalarMapper implementations.
Declaration
IDictionary<Type, IScalarMapper>? ScalarMappers { get; }
Property Value
| Type | Description |
|---|---|
| IDictionary<Type, IScalarMapper> |
Substring
Gets the SQL syntax representation for the substring function.
Declaration
string Substring { get; }
Property Value
| Type | Description |
|---|---|
| string |
TruncateTable
Gets the SQL statement used to truncate (remove all rows from) a table.
Declaration
string TruncateTable { get; }
Property Value
| Type | Description |
|---|---|
| string |
UpdateData
Gets the SQL syntax template used for constructing an UPDATE statement to modify data in a table.
Declaration
string UpdateData { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceAlterSequences(IUmbracoDatabase)
Alters the database sequences to match the current schema requirements.
Declaration
void AlterSequences(IUmbracoDatabase database)
Parameters
| Type | Name | Description |
|---|---|---|
| IUmbracoDatabase | database | The database connection to use for altering sequences. |
Remarks
This is an optional extension point for SQL providers that support database sequences. Providers that support sequences should override this method and implement any required changes when schema updates (for example, after a migration) require sequence adjustments. Callers should typically check SupportsSequences() before invoking this method. The default implementation throws System.NotImplementedException.
AlterSequences(IUmbracoDatabase, string)
Alters the database sequences associated with the specified table for providers that support sequences.
Declaration
void AlterSequences(IUmbracoDatabase database, string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| IUmbracoDatabase | database | The database connection to use for altering the sequences. |
| string | tableName | The name of the table whose sequences will be altered. |
Remarks
This is an optional extension point for SQL providers that support database sequences. Providers that support sequences should override this method to update sequences associated with the specified table when schema changes require it. Callers should typically check SupportsSequences() before invoking this method. The default implementation throws System.NotImplementedException.
AppendForUpdateHint(Sql<ISqlContext>)
Appends the relevant FOR UPDATE hint to the specified SQL query, if applicable for the underlying database.
Declaration
Sql<ISqlContext> AppendForUpdateHint(Sql<ISqlContext> sql)
Parameters
| Type | Name | Description |
|---|---|---|
| Sql<ISqlContext> | sql | The SQL query to which the FOR UPDATE hint will be appended. |
Returns
| Type | Description |
|---|---|
| Sql<ISqlContext> | A NPoco.Sql<> instance with the FOR UPDATE hint appended, if supported. |
ColumnWithAlias(string, string, string)
Returns a column name with an alias, optionally prefixed by a table name or alias.
Declaration
string ColumnWithAlias(string tableNameOrAlias, string columnName, string columnAlias = "")
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableNameOrAlias | The table name or alias to prefix the column with. |
| string | columnName | The name of the column. |
| string | columnAlias | The alias to assign to the column. |
Returns
| Type | Description |
|---|---|
| string | A string representing the column with its alias, optionally prefixed by the table name or alias. |
ConvertIntegerToBoolean(int)
Converts the specified integer value to its equivalent boolean representation in SQL syntax.
Declaration
string ConvertIntegerToBoolean(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The integer value to convert (typically 0 or 1). |
Returns
| Type | Description |
|---|---|
| string | A string containing the SQL representation of the boolean value. |
CreateTempTable(string, string)
Gets the SQL to create a temporary table with the given name and column definitions.
Declaration
string CreateTempTable(string tableName, string columnDefinitionSql)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The base name for the temporary table (without any provider-specific prefix). |
| string | columnDefinitionSql | The SQL column definitions (e.g., "Id INT NOT NULL PRIMARY KEY"). |
Returns
| Type | Description |
|---|---|
| string | A SQL statement that creates the temporary table. |
DoesPrimaryKeyExist(IDatabase, string, string)
Determines whether the specified primary key exists on the given table.
Declaration
bool DoesPrimaryKeyExist(IDatabase db, string tableName, string primaryKeyName)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db | The database instance to use for the check. |
| string | tableName | The name of the table to check. |
| string | primaryKeyName | The name of the primary key to look for. |
Returns
| Type | Description |
|---|---|
| bool | True if the primary key exists; otherwise, false. |
DoesTableExist(IDatabase, string)
Determines whether the specified table exists in the database.
Declaration
bool DoesTableExist(IDatabase db, string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db | The database instance to check the table in. |
| string | tableName | The name of the table to check for existence. |
Returns
| Type | Description |
|---|---|
| bool | True if the table exists; otherwise, false. |
DropTempTable(string)
Gets the SQL to drop a temporary table if it exists.
Declaration
string DropTempTable(string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The base name for the temporary table (without any provider-specific prefix). |
Returns
| Type | Description |
|---|---|
| string | A SQL statement that drops the temporary table if it exists. |
EscapeString(string)
Escapes a string value for safe inclusion in SQL queries, helping to prevent SQL injection attacks.
Declaration
string EscapeString(string val)
Parameters
| Type | Name | Description |
|---|---|---|
| string | val | The string value to escape. |
Returns
| Type | Description |
|---|---|
| string | The escaped string safe for use in SQL queries. |
Format(IEnumerable<ColumnDefinition>)
Formats a collection of ColumnDefinition objects into their SQL string representation.
Declaration
string Format(IEnumerable<ColumnDefinition> columns)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ColumnDefinition> | columns | The collection of columns to format. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the formatted columns. |
Format(IEnumerable<ForeignKeyDefinition>)
Formats a collection of foreign key definitions into their corresponding SQL statements.
Declaration
List<string> Format(IEnumerable<ForeignKeyDefinition> foreignKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ForeignKeyDefinition> | foreignKeys | The foreign key definitions to format. |
Returns
| Type | Description |
|---|---|
| List<string> | A list of SQL strings representing the formatted foreign keys. |
Format(IEnumerable<IndexDefinition>)
Formats a collection of IndexDefinition objects into their corresponding SQL statements.
Declaration
List<string> Format(IEnumerable<IndexDefinition> indexes)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IndexDefinition> | indexes | The collection of index definitions to be formatted. |
Returns
| Type | Description |
|---|---|
| List<string> | A list of SQL strings representing the formatted index definitions. |
Format(ColumnDefinition)
Formats the specified ColumnDefinition into its SQL representation.
Declaration
string Format(ColumnDefinition column)
Parameters
| Type | Name | Description |
|---|---|---|
| ColumnDefinition | column | The ColumnDefinition to format. |
Returns
| Type | Description |
|---|---|
| string | A SQL string that defines the column according to the provider's syntax. |
Format(ColumnDefinition, string, out IEnumerable<string>)
Formats a ColumnDefinition into its corresponding SQL statement for the specified table.
Declaration
string Format(ColumnDefinition column, string tableName, out IEnumerable<string> sqls)
Parameters
| Type | Name | Description |
|---|---|---|
| ColumnDefinition | column | The ColumnDefinition to format. |
| string | tableName | The name of the table the column belongs to. |
| IEnumerable<string> | sqls | Outputs additional SQL statements required for the column definition. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the column definition. |
Format(ForeignKeyDefinition)
Formats the specified foreign key definition into a SQL string.
Declaration
string Format(ForeignKeyDefinition foreignKey)
Parameters
| Type | Name | Description |
|---|---|---|
| ForeignKeyDefinition | foreignKey | The foreign key definition to format. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the foreign key definition. |
Format(IndexDefinition)
Formats the specified IndexDefinition into its corresponding SQL statement.
Declaration
string Format(IndexDefinition index)
Parameters
| Type | Name | Description |
|---|---|---|
| IndexDefinition | index | The IndexDefinition to format. |
Returns
| Type | Description |
|---|---|
| string | A SQL string that defines the specified index. |
Format(TableDefinition)
Formats a TableDefinition into its corresponding SQL statement.
Declaration
string Format(TableDefinition table)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDefinition | table | The TableDefinition to format. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the table definition. |
FormatColumnRename(string?, string?, string?)
Formats the SQL syntax for renaming a column in a table.
Declaration
string FormatColumnRename(string? tableName, string? oldName, string? newName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The name of the table containing the column to rename. |
| string | oldName | The current name of the column. |
| string | newName | The new name for the column. |
Returns
| Type | Description |
|---|---|
| string | A SQL string that performs the column rename operation. |
FormatDateTime(DateTime, bool)
Formats a System.DateTime value as a string suitable for use in SQL queries.
Declaration
string FormatDateTime(DateTime date, bool includeTime = true)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | date | The date and time value to format. |
| bool | includeTime | If |
Returns
| Type | Description |
|---|---|
| string | A string representation of the date (and optionally time) formatted for SQL. |
FormatGuid(Guid)
Formats a System.Guid value as a string suitable for use in SQL queries.
Declaration
string FormatGuid(Guid guid)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | guid | The guid. |
Returns
| Type | Description |
|---|---|
| string | A string representation of the guid formatted for SQL. |
FormatPrimaryKey(TableDefinition)
Generates the SQL statement for defining the primary key of the specified table.
Declaration
string FormatPrimaryKey(TableDefinition table)
Parameters
| Type | Name | Description |
|---|---|---|
| TableDefinition | table | The TableDefinition representing the table whose primary key definition is to be formatted. |
Returns
| Type | Description |
|---|---|
| string | A string containing the SQL definition for the primary key. |
FormatTableRename(string?, string?)
Formats the SQL statement to rename a table from an old name to a new name.
Declaration
string FormatTableRename(string? oldName, string? newName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldName | The current name of the table. |
| string | newName | The new name for the table. |
Returns
| Type | Description |
|---|---|
| string | A SQL string that performs the table rename operation. |
GetColumn(DatabaseType, string, string, string?, string?, bool)
Returns the SQL representation of a column for a given database type, table, and column name, with optional aliasing and reference for joins.
Declaration
string GetColumn(DatabaseType dbType, string tableName, string columnName, string? columnAlias, string? referenceName = null, bool forInsert = false)
Parameters
| Type | Name | Description |
|---|---|---|
| DatabaseType | dbType | The database type (e.g., SQL Server, MySQL). |
| string | tableName | The name of the table containing the column. |
| string | columnName | The name of the column. |
| string | columnAlias | An optional alias to use for the column in the SQL statement. |
| string | referenceName | An optional reference name, typically used as a table alias in join scenarios. |
| bool | forInsert | True if the column is being used in an INSERT statement; otherwise, false. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the column, formatted appropriately for the specified database type and context. |
GetColumnsInSchema(IDatabase)
Retrieves information about all columns defined in the schema of the specified database.
Declaration
IEnumerable<ColumnInfo> GetColumnsInSchema(IDatabase db)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db | The NPoco.IDatabase instance representing the database to inspect. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ColumnInfo> | An System.Collections.Generic.IEnumerable<T> containing details for each column in the database schema. |
GetConcat(params string[])
Concatenates the specified string arguments into a single string using the SQL syntax appropriate for the database.
Declaration
string GetConcat(params string[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | args | The string arguments to concatenate. |
Returns
| Type | Description |
|---|---|
| string | A string representing the SQL concatenation of the arguments. |
GetConstraintsPerColumn(IDatabase)
Returns all constraints defined in the database (Primary keys, foreign keys, unique constraints...) (does not include indexes)
Declaration
IEnumerable<Tuple<string, string, string>> GetConstraintsPerColumn(IDatabase db)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db |
Returns
| Type | Description |
|---|---|
| IEnumerable<Tuple<string, string, string>> | A Tuple containing: TableName, ColumnName, ConstraintName |
GetConstraintsPerTable(IDatabase)
Returns all constraints defined in the database (Primary keys, foreign keys, unique constraints...) (does not include indexes)
Declaration
IEnumerable<Tuple<string, string>> GetConstraintsPerTable(IDatabase db)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db |
Returns
| Type | Description |
|---|---|
| IEnumerable<Tuple<string, string>> | A Tuple containing: TableName, ConstraintName |
GetDefinedIndexes(IDatabase)
Returns all defined Indexes in the database excluding primary keys
Declaration
IEnumerable<Tuple<string, string, string, bool>> GetDefinedIndexes(IDatabase db)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db |
Returns
| Type | Description |
|---|---|
| IEnumerable<Tuple<string, string, string, bool>> | A Tuple containing: TableName, IndexName, ColumnName, IsUnique |
GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object?>>, string?)
Returns the formatted field name to be used in an SQL UPDATE statement for the specified field selector.
Declaration
string GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object?>> fieldSelector, string? tableAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<TDto, object>> | fieldSelector | An expression selecting the field from the DTO. |
| string | tableAlias | An optional table alias to prefix the field name; if |
Returns
| Type | Description |
|---|---|
| string | The formatted field name, suitable for use in an UPDATE statement. |
Type Parameters
| Name | Description |
|---|---|
| TDto | The type of the data transfer object (DTO) containing the field. |
GetIndexType(IndexTypes)
Returns the SQL keyword or expression that represents the specified index type.
Declaration
string GetIndexType(IndexTypes indexTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| IndexTypes | indexTypes | The IndexTypes value specifying the type of index. |
Returns
| Type | Description |
|---|---|
| string | A string containing the SQL representation of the index type. |
GetNullCastSuffix<T>()
Gets the SQL type cast extension (null type annotation) associated with a null value for the specified type parameter.
Declaration
string GetNullCastSuffix<T>()
Returns
| Type | Description |
|---|---|
| string | A string containing the SQL type cast extension (null type annotation) that represents a null value for type
|
Type Parameters
| Name | Description |
|---|---|
| T | The type for which to retrieve the SQL null type annotation. |
Remarks
This method is useful when generating SQL queries that require explicit type casting of NULL values,
such as in PostgreSQL. The returned string can be used directly in SQL statements for type-safe
comparisons or assignments (for example, ::integer or ::text).
GetQuotedColumnName(string?)
Returns the specified column name with appropriate SQL identifier quoting applied, according to the current SQL dialect.
Declaration
string GetQuotedColumnName(string? columnName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | columnName | The name of the column to be quoted. Can be |
Returns
| Type | Description |
|---|---|
| string | The quoted column name as a string. |
GetQuotedName(string?)
Returns the specified SQL identifier name properly quoted for use in SQL queries, according to the syntax rules of the underlying database.
Declaration
string GetQuotedName(string? name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The SQL identifier name to quote. May be |
Returns
| Type | Description |
|---|---|
| string | The quoted name as a string, or |
GetQuotedTableName(string?)
Returns the specified table name properly quoted for use in SQL statements, according to the SQL dialect.
Declaration
string GetQuotedTableName(string? tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The name of the table to be quoted. Can be |
Returns
| Type | Description |
|---|---|
| string | The quoted table name as a string. |
GetQuotedValue(string)
Returns the specified string value properly quoted for safe inclusion in an SQL statement.
Declaration
string GetQuotedValue(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string value to be quoted. |
Returns
| Type | Description |
|---|---|
| string | The input string value wrapped in appropriate SQL quotes. |
GetSpecialDbType(SpecialDbType)
Returns the SQL type declaration string corresponding to the specified SpecialDbType.
Declaration
string GetSpecialDbType(SpecialDbType dbType)
Parameters
| Type | Name | Description |
|---|---|---|
| SpecialDbType | dbType | The special database type for which to retrieve the SQL type declaration. |
Returns
| Type | Description |
|---|---|
| string | A string containing the SQL type declaration for the given special database type. |
GetStringColumnEqualComparison(string, int, TextColumnType)
Constructs a SQL expression that compares a string column to a parameter value for equality, using the appropriate syntax for the specified text column type.
Declaration
string GetStringColumnEqualComparison(string column, int paramIndex, TextColumnType columnType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | column | The name of the string column to compare. |
| int | paramIndex | The index of the parameter placeholder to use in the SQL statement. |
| TextColumnType | columnType | The type of the text column, which may affect how the comparison is performed (e.g., case sensitivity or collation). |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the equality comparison between the column and the parameter. |
GetStringColumnWildcardComparison(string, int, TextColumnType)
Constructs a SQL WHERE clause fragment for performing a wildcard comparison on a specified text column.
Declaration
string GetStringColumnWildcardComparison(string column, int paramIndex, TextColumnType columnType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | column | The name of the column to compare. |
| int | paramIndex | The index of the parameter to use in the comparison (for parameterized queries). |
| TextColumnType | columnType | The type of the text column, which may affect how the comparison is constructed. |
Returns
| Type | Description |
|---|---|
| string | A string representing the SQL WHERE clause fragment for a wildcard comparison on the specified column. |
GetTablesInSchema(IDatabase)
Returns the names of all tables in the schema for the specified database.
Declaration
IEnumerable<string> GetTablesInSchema(IDatabase db)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db | The database from which to retrieve table names. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable collection of table names in the schema. |
GetUpdatedDatabaseType(DatabaseType, string?)
Determines the appropriate database type based on the specified current type and an optional connection string.
Declaration
DatabaseType GetUpdatedDatabaseType(DatabaseType current, string? connectionString)
Parameters
| Type | Name | Description |
|---|---|---|
| DatabaseType | current | The current NPoco.DatabaseType. |
| string | connectionString | An optional connection string used to help determine the updated database type. |
Returns
| Type | Description |
|---|---|
| DatabaseType | The resolved Umbraco.Cms.Infrastructure.Persistence.DatabaseType. |
GetWildcardConcat(string)
This ensures that GetWildcardPlaceholder() character is surronded by '' when used inside a LIKE statement. E.g. in WhereLike() extension and the defaultConcat is used.
Declaration
string GetWildcardConcat(string concatDefault = "")
Parameters
| Type | Name | Description |
|---|---|---|
| string | concatDefault | When provided this overides the GetWildcardPlaceholder() default. |
Returns
| Type | Description |
|---|---|
| string |
GetWildcardPlaceholder()
Returns the SQL wildcard placeholder string used for parameterized LIKE queries.
Declaration
string GetWildcardPlaceholder()
Returns
| Type | Description |
|---|---|
| string | The SQL wildcard placeholder string (e.g., "%" or "*"). |
HandleCreateTable(IDatabase, TableDefinition, bool)
Creates a table in the specified database using the provided table definition.
Declaration
void HandleCreateTable(IDatabase database, TableDefinition tableDefinition, bool skipKeysAndIndexes = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | database | The NPoco.IDatabase instance where the table will be created. |
| TableDefinition | tableDefinition | The TableDefinition describing the table schema. |
| bool | skipKeysAndIndexes | If set to |
InsertForUpdateHint(Sql<ISqlContext>)
Appends the appropriate FOR UPDATE hint to the specified SQL query, if applicable for the database dialect.
Declaration
Sql<ISqlContext> InsertForUpdateHint(Sql<ISqlContext> sql)
Parameters
| Type | Name | Description |
|---|---|---|
| Sql<ISqlContext> | sql | The SQL query to which the FOR UPDATE hint will be appended. |
Returns
| Type | Description |
|---|---|
| Sql<ISqlContext> | The modified SQL query with the FOR UPDATE hint appended, or the original query if not applicable. |
LeftJoinWithNestedJoin<TDto>(Sql<ISqlContext>, Func<Sql<ISqlContext>, Sql<ISqlContext>>, string?)
Handles left join with nested join
Declaration
Sql<ISqlContext>.SqlJoinClause<ISqlContext> LeftJoinWithNestedJoin<TDto>(Sql<ISqlContext> sql, Func<Sql<ISqlContext>, Sql<ISqlContext>> nestedJoin, string? alias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Sql<ISqlContext> | sql | |
| Func<Sql<ISqlContext>, Sql<ISqlContext>> | nestedJoin | |
| string | alias |
Returns
| Type | Description |
|---|---|
| SqlJoinClause<ISqlContext> |
Type Parameters
| Name | Description |
|---|---|
| TDto |
OrderByGuid(string, string)
Generates the SQL ORDER BY clause for a GUID column in the specified table.
Declaration
string OrderByGuid(string tableName, string columnName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The name of the table containing the GUID column. |
| string | columnName | The name of the GUID column to order by. |
Returns
| Type | Description |
|---|---|
| string | A SQL string representing the ORDER BY clause for the specified GUID column. |
SelectTop(Sql<ISqlContext>, int)
Modifies the given SQL query to limit the result set to the specified number of rows.
Declaration
Sql<ISqlContext> SelectTop(Sql<ISqlContext> sql, int top)
Parameters
| Type | Name | Description |
|---|---|---|
| Sql<ISqlContext> | sql | The SQL query to be modified. |
| int | top | The maximum number of rows to return. |
Returns
| Type | Description |
|---|---|
| Sql<ISqlContext> | The modified SQL query limited to the specified number of rows. |
SupportsClustered()
Determines whether the SQL syntax provider supports clustered indexes.
Declaration
bool SupportsClustered()
Returns
| Type | Description |
|---|---|
| bool |
|
SupportsIdentityInsert()
Determines whether the SQL syntax provider supports identity insert operations.
Declaration
bool SupportsIdentityInsert()
Returns
| Type | Description |
|---|---|
| bool |
|
SupportsSequences()
Determines whether the current database provider supports sequence objects for generating numeric values like PostgreSQL.
Declaration
bool SupportsSequences()
Returns
| Type | Description |
|---|---|
| bool | true if the provider supports sequences; otherwise, false. |
TempTableName(string)
Gets the properly qualified name for a temporary table, applying any provider-specific prefix.
Declaration
string TempTableName(string baseName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | baseName | The base name for the temporary table. |
Returns
| Type | Description |
|---|---|
| string | The qualified temporary table name. |
TruncateConstraintName<T>(string)
Some databases have a maximum length for constraint names, this method truncates the name if necessary.
Declaration
string TruncateConstraintName<T>(string constraintName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | constraintName | unlimited name. |
Returns
| Type | Description |
|---|---|
| string | truncated name. |
Type Parameters
| Name | Description |
|---|---|
| T | type of the entity. |
TryGetDefaultConstraint(IDatabase, string?, string, out string)
Tries to gets the name of the default constraint on a column.
Declaration
bool TryGetDefaultConstraint(IDatabase db, string? tableName, string columnName, out string constraintName)
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabase | db | The database. |
| string | tableName | The table name. |
| string | columnName | The column name. |
| string | constraintName | The constraint name. |
Returns
| Type | Description |
|---|---|
| bool | A value indicating whether a default constraint was found. |
Remarks
Some database engines may not have names for default constraints,
in which case the function may return true, but constraintName is
unspecified.