PostgreSqlDialect
PostgreSQL dialect implementation.
Herda de: SqlDialectBase
Propriedades
public override string BooleanCastSqlType { get; }
value = postgreSqlDialect.BooleanCastSqlType
SQL type name to cast a boolean expression to when materialising EXISTS(...) projections (e.g. bit on SQL Server). Return if the dialect represents booleans natively and no cast is needed (e.g. PostgreSQL).
public override string ConcatOperator { get; }
value = postgreSqlDialect.ConcatOperator
SQL string concatenation operator.
public override string EmptyBinaryLiteral { get; }
value = postgreSqlDialect.EmptyBinaryLiteral
SQL literal for an empty binary value (e.g. 0x for SQL Server, X'' for the SQL standard, an empty bytea for PostgreSQL).
public override string FalseLiteral { get; }
value = postgreSqlDialect.FalseLiteral
SQL literal for boolean false.
public override string IsNullFunction { get; }
value = postgreSqlDialect.IsNullFunction
Function name for null-coalescing.
public override string LenFunction { get; }
value = postgreSqlDialect.LenFunction
Function name for string length.
public override int MaxParameters { get; }
value = postgreSqlDialect.MaxParameters
Maximum number of parameters allowed in a single statement. SQL Server: 2100, SQLite: 999, PostgreSQL: 65535, MySQL: 65535.
public override string ParameterPrefix { get; }
value = postgreSqlDialect.ParameterPrefix
Parameter prefix (e.g. @ for SQL Server, $ for PostgreSQL).
public override bool SupportsInsertReturning { get; }
value = postgreSqlDialect.SupportsInsertReturning
True when this dialect can return a server-generated identity in the same statement via String); callers use it to choose between a single-statement INSERT…RETURNING and a two-statement INSERT + SELECT identity batch.
public override string TrueLiteral { get; }
value = postgreSqlDialect.TrueLiteral
SQL literal for boolean true.
public override string UnicodePrefix { get; }
value = postgreSqlDialect.UnicodePrefix
Unicode string-literal prefix (e.g. N for SQL Server).
Métodos
public override void AppendAlterColumn(StringBuilder sb, string tableName, string columnName, Type clrType, bool isNullable, int maxLength, int precision, int scale, DbColumnInfo live)
postgreSqlDialect.AppendAlterColumn(sb, tableName, columnName, clrType, isNullable, maxLength, precision, scale, live)
Appends ALTER TABLE ALTER COLUMN that gives a column the declared type and nullability.
- sb
- Where the statement goes.
- tableName
- The table.
- columnName
- The column.
- clrType
- The property type the column holds.
- isNullable
- Whether the column should allow NULLs.
- maxLength
- The declared length, 0 for the default.
- precision
- The declared precision, 0 for the default.
- scale
- The declared scale.
- live
- The column as the database holds it, or null for a column this script has just added; a dialect uses it to keep what the declaration does not decide, and to convert the stored values.
public override void AppendAlterNullability(StringBuilder sb, string tableName, string columnName, bool isNullable, DbColumnInfo live)
postgreSqlDialect.AppendAlterNullability(sb, tableName, columnName, isNullable, live)
Makes a column nullable or not, leaving its type as the database holds it.
- sb
- Where the statement goes.
- tableName
- The table.
- columnName
- The column.
- isNullable
- Whether the column should allow NULLs.
- live
- The column as the database holds it.
public override void AppendCreateTable(StringBuilder sb, string tableName, string columnDefs)
postgreSqlDialect.AppendCreateTable(sb, tableName, columnDefs)
Appends CREATE TABLE [IF NOT EXISTS] statement.
public override void AppendDateAdd(StringBuilder sb, string part, string amountSql, string sourceSql)
postgreSqlDialect.AppendDateAdd(sb, part, amountSql, sourceSql)
Appends a DATEADD-style expression.
public override void AppendDateDiff(StringBuilder sb, string part, string startSql, string endSql)
postgreSqlDialect.AppendDateDiff(sb, part, startSql, endSql)
Appends a DATEDIFF-style expression computing minus , expressed in units.
- sb
- Target builder.
- part
- Unit of the result: year, month, week, day, hour, minute, second or millisecond.
- startSql
- SQL of the start date.
- endSql
- SQL of the end date.
public override void AppendDatePartClose(StringBuilder sb)
postgreSqlDialect.AppendDatePartClose(sb)
Closes a date-part extraction expression opened by String).
public override void AppendDatePartOpen(StringBuilder sb, string part)
postgreSqlDialect.AppendDatePartOpen(sb, part)
Opens a date-part extraction expression (closed by StringBuilder)).
public override void AppendDropTable(StringBuilder sb, string tableName)
postgreSqlDialect.AppendDropTable(sb, tableName)
Appends DROP TABLE [IF EXISTS] statement.
public override void AppendFallbackOrderBy(StringBuilder sb)
postgreSqlDialect.AppendFallbackOrderBy(sb)
Appends a fallback ORDER BY clause when there is neither explicit ordering nor an identity column. SQL Server requires ORDER BY for OFFSET/FETCH; other dialects may emit a deterministic shim or nothing at all.
public override void AppendGreatest(StringBuilder sb, string leftSql, string rightSql)
postgreSqlDialect.AppendGreatest(sb, leftSql, rightSql)
Appends the larger of two values, the way Decimal) picks it: a scalar function of two arguments, not the MAX aggregate.
- sb
- Target builder.
- leftSql
- SQL of the first value.
- rightSql
- SQL of the second value.
public override void AppendInsertReturningClause(StringBuilder sb, string idColumn)
postgreSqlDialect.AppendInsertReturningClause(sb, idColumn)
Appends a dialect-specific RETURNING clause to an INSERT, scoped to the given identity column. PostgreSQL emits RETURNING "Id"; SQL Server and SQLite have other identity-read mechanisms and emit nothing here.
public override void AppendLeast(StringBuilder sb, string leftSql, string rightSql)
postgreSqlDialect.AppendLeast(sb, leftSql, rightSql)
Appends the smaller of two values, the way Decimal) picks it: a scalar function of two arguments, not the MIN aggregate.
- sb
- Target builder.
- leftSql
- SQL of the first value.
- rightSql
- SQL of the second value.
public override void AppendPagination(StringBuilder sb, long? skip, long? take, bool hasOrderBy)
postgreSqlDialect.AppendPagination(sb, skip, take, hasOrderBy)
Appends literal pagination (LIMIT/OFFSET or OFFSET/FETCH) with values.
public override void AppendPaginationParams(StringBuilder sb, string skipParamExpr, string takeParamExpr)
postgreSqlDialect.AppendPaginationParams(sb, skipParamExpr, takeParamExpr)
Appends parameterised pagination with already-prefixed parameter expressions (e.g. @skip, @take).
public override void AppendTrimClose(StringBuilder sb)
postgreSqlDialect.AppendTrimClose(sb)
Closes a TRIM expression opened by StringBuilder).
public override void AppendTrimOpen(StringBuilder sb)
postgreSqlDialect.AppendTrimOpen(sb)
Opens a TRIM expression (closed by StringBuilder)).
protected override void AppendTruncate(StringBuilder sb, string valueSql, string digitsSql)
postgreSqlDialect.AppendTruncate(sb, valueSql, digitsSql)
Appends an expression that drops the digits of a value beyond , rounding toward zero.
- sb
- Target builder.
- valueSql
- SQL of the value.
- digitsSql
- SQL of the number of fractional digits to keep, or for a whole number.
public override void AppendUpsert(StringBuilder sb, string tableName, string[] allColumns, string[] keyColumns)
postgreSqlDialect.AppendUpsert(sb, tableName, allColumns, keyColumns)
Appends a UPSERT statement (MERGE on SQL Server, INSERT … ON CONFLICT on PostgreSQL/SQLite).
public override string FormatSkip(string skip)
result = postgreSqlDialect.FormatSkip(skip)
Renders a SKIP/OFFSET clause from a parameter expression.
public override string FormatTake(string take)
result = postgreSqlDialect.FormatTake(take)
Renders a TAKE/FETCH clause from a parameter expression.
public override string GetColumnTypeName(Type clrType, int maxLength, int precision, int scale)
result = postgreSqlDialect.GetColumnTypeName(clrType, maxLength, precision, scale)
The SQL type a column is created with: the type name together with its length, precision or scale. A decimal that declares only a scale gets DefaultDecimalPrecision; one that declares a precision keeps its scale as declared, zero included.
public override string GetIdentityColumnSuffix()
result = postgreSqlDialect.GetIdentityColumnSuffix()
Suffix for an identity (auto-increment primary key) column definition.
public override string GetIdentitySelect(string idCol)
result = postgreSqlDialect.GetIdentitySelect(idCol)
SQL expression that returns the identity value of the last insert.
public override string GetSqlTypeName(Type clrType)
result = postgreSqlDialect.GetSqlTypeName(clrType)
Returns the SQL type name for a CLR type.
public override string GetSqlTypeName(Type clrType, int maxLength)
result = postgreSqlDialect.GetSqlTypeName(clrType, maxLength)
Canonical SQL type name with length applied. Dialects override when the type differs by length (e.g. PostgreSQL TEXT vs VARCHAR(N)).
public override string NewId()
result = postgreSqlDialect.NewId()
Generates a new unique identifier.
public override string NormalizeDbType(string dbTypeName)
result = postgreSqlDialect.NormalizeDbType(dbTypeName)
Normalises a raw database type name to the canonical form used by this dialect.
public override void PrepareParameter(DbParameter parameter)
postgreSqlDialect.PrepareParameter(parameter)
Final-stage massaging of a fully populated DbParameter before it leaves the ORM layer. Lets a dialect adjust provider-specific type metadata that the generic DbType hint can't express — e.g. PostgreSQL needs timestamptz binding for UTC-kind DateTime values, which only Npgsql's own NpgsqlDbType property can express. Default is a no-op.
public override string QuoteIdentifier(string identifier)
result = postgreSqlDialect.QuoteIdentifier(identifier)
Quotes an identifier (table name, column name).
public override Task<IReadOnlyList<DbForeignKeyInfo>> ReadDbForeignKeysAsync(DbConnection connection, string tableSchema, CancellationToken cancellationToken)
result = postgreSqlDialect.ReadDbForeignKeysAsync(connection, tableSchema, cancellationToken)
Reads foreign-key metadata from a live database. Used by the schema migrator to detect missing/extra FK constraints on tables that already exist.
- connection
- An open database connection.
- tableSchema
- Schema name (e.g. "dbo" or "public"); dialect default when .
- cancellationToken
- Cancellation token.
Retorna: One row per FK column — compound FKs surface as multiple rows.
public override Task<IReadOnlyList<DbIndexInfo>> ReadDbIndexesAsync(DbConnection connection, string tableSchema, CancellationToken cancellationToken)
result = postgreSqlDialect.ReadDbIndexesAsync(connection, tableSchema, cancellationToken)
Reads index metadata from a live database. Used by the schema migrator to detect missing entity-declared [Index] / [Unique] attributes on tables that already exist. Composite indexes are returned as multiple rows sharing IndexName with ascending ColumnOrdinal.
- connection
- An open database connection.
- tableSchema
- Schema name (e.g. "dbo" or "public"); dialect default when .
- cancellationToken
- Cancellation token.
Retorna: One row per indexed column — composite indexes surface as multiple rows.
public override Task<IReadOnlyList<DbColumnInfo>> ReadDbSchemaAsync(DbConnection connection, string tableSchema, CancellationToken cancellationToken)
result = postgreSqlDialect.ReadDbSchemaAsync(connection, tableSchema, cancellationToken)
Reads column metadata from a live database.
public static void Register(DbProviderFactory factory)
PostgreSqlDialect.Register(factory)
Registers the PostgreSQL dialect and provider factory with DatabaseProviderRegistry.
- factory
- The DbProviderFactory for PostgreSQL.
public override string SysNow()
result = postgreSqlDialect.SysNow()
System local date/time with offset.
public override string SysUtcNow()
result = postgreSqlDialect.SysUtcNow()
System UTC date/time with offset.
Campos
public static readonly PostgreSqlDialect Instance
value = PostgreSqlDialect.Instance
Singleton instance.