Class SqlServerDialect
SQL Server's SQL flavour: snake_case naming, [bracketed] identifiers, OFFSET/FETCH paging
(which demands an ORDER BY — the engine adds a deterministic key order when the query has none),
IDENTITY keys read back with OUTPUT INSERTED, and (1=0) for the empty-IN literal.
Collection columns and row-wise tuple comparisons do not exist; those clauses degrade to the gated
client-side residual.
public class SqlServerDialect : SqlDialect
- Inheritance
-
SqlServerDialect
- Inherited Members
Constructors
SqlServerDialect()
Initializes the dialect (T-SQL date parts instead of EXTRACT).
public SqlServerDialect()
Properties
FalseLiteral
The literal for an always-false predicate (an empty IN); some dialects have no FALSE.
public override string FalseLiteral { get; }
Property Value
GeneratedKeyDdl
The DDL column suffix declaring a database-generated key (e.g. GENERATED BY DEFAULT AS IDENTITY).
public override string GeneratedKeyDdl { get; }
Property Value
RequiresOrderByForLimit
Whether a limited query must carry an ORDER BY (SQL Server's OFFSET/FETCH); the key is used when unsorted.
public override bool RequiresOrderByForLimit { get; }
Property Value
System
The OpenTelemetry db.system value (e.g. postgresql, mysql, mssql).
public override string System { get; }
Property Value
Methods
AlterColumnType(string, string, string)
The DDL altering a column's type (a dialect may need a cast clause).
public override string AlterColumnType(string quotedTable, string quotedColumn, string sqlType)
Parameters
Returns
BindValue(object?)
Converts a value before binding (a dialect may need CLR-side coercion, e.g. arrays); identity by default.
public override object? BindValue(object? value)
Parameters
valueobject
Returns
CreateIndexSql(string, string, string, bool, IndexMethod, string?)
The DDL creating an index with a structure and an optional filtered predicate (already rendered as a SQL fragment with inlined literals). The base dialect builds default-structure indexes, filtered or not; a method it has no structure for is rejected with guidance.
public override string CreateIndexSql(string quotedName, string quotedTable, string columns, bool unique, IndexMethod method, string? filter)
Parameters
quotedNamestringThe quoted index name.
quotedTablestringThe quoted table.
columnsstringThe rendered key column list.
uniqueboolWhether the index enforces uniqueness.
methodIndexMethodThe index structure.
filterstringThe rendered partial-index predicate, or
null.
Returns
CreateTableSql(string, string)
Builds an idempotent CREATE TABLE statement.
public override string CreateTableSql(string quotedTable, string columnsDdl)
Parameters
Returns
InsertSql(string, string, string, string?)
Builds an INSERT, reading the generated key back when returningKey is supplied
(RETURNING / OUTPUT INSERTED). The base dialect cannot read keys back — declare a
client-generated key, or use a dialect that can.
public override string InsertSql(string quotedTable, string columns, string values, string? returningKey)
Parameters
quotedTablestringThe quoted table.
columnsstringThe quoted column list.
valuesstringThe bound value list.
returningKeystringThe quoted generated-key column to read back, or
null.
Returns
LimitClause(string, string?)
The SQL fragment limiting a query to the bound row count after the bound offset (appended after ORDER BY).
public override string LimitClause(string limitParameter, string? offsetParameter)
Parameters
Returns
Literal(object?)
Renders a value as an inline SQL literal — DDL (a filtered index's predicate) cannot carry bind parameters. Values a dialect cannot inline are rejected with guidance.
public override string Literal(object? value)
Parameters
valueobjectThe value (already normalized by BindValue(object?)).
Returns
Remarks
SQL Server booleans are bit: literals inline as 1/0.
Quote(string)
Quotes an identifier (table or column name).
public override string Quote(string identifier)
Parameters
identifierstring
Returns
SizedTextType(int)
The sized text type — nvarchar(n) on SQL Server.
protected override string SizedTextType(int length)
Parameters
lengthintThe maximum length.
Returns
SqlType(Type)
The DDL type for a CLR type (used by CREATE TABLE migrations).
public override string SqlType(Type type)
Parameters
typeType