PostgresTypeMapper
Postgres dialect type mapping: SQL type name + CLR type + nullability →
C# type literal + reader call shapes. Used by
and.
public static class PostgresTypeMapper
Methods
MapPostgresTypeToCSharp(string, bool)
public static string MapPostgresTypeToCSharp(string pgType, bool isNullable)
Maps a Postgres SQL type name (as reported by the driver or an LQL
schema file) to a C# type literal. Honours
isNullable for value types and strings, but always
returns byte[]? for bytea because Postgres metadata for
that type is unreliable (see bug #14 in the original monolith).
Parameters:
| Name | Type | Description |
|---|---|---|
pgType |
String |
The Postgres SQL type name. |
isNullable |
Boolean |
Whether the column is nullable. |
Returns: String - A C# type literal suitable for emission in generated code.
MapPortableTypeToCSharp(PortableType, bool)
public static string MapPortableTypeToCSharp(PortableType type, bool isNullable)
Maps a `` (LQL schema-derived) to a C# type literal.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
PortableType |
The portable type. |
isNullable |
Boolean |
Whether the column is nullable. |
Returns: String - A C# type literal.
GetReaderExpression(DatabaseColumn, int)
public static string GetReaderExpression(DatabaseColumn col, int ordinal)
Returns the reader-call expression used in generated code to read a column at the supplied ordinal into its C# type.
Parameters:
| Name | Type | Description |
|---|---|---|
col |
DatabaseColumn |
The database column (supplies the C# type + nullability). |
ordinal |
Int32 |
The column ordinal in the reader. |
Returns: String - A C# expression of the form reader.GetXxx(N).
InferParameterType(string, IReadOnlyList<DatabaseColumn>?)
public static string InferParameterType(string paramName, IReadOnlyList<DatabaseColumn>? columns = null)
Infers a parameter's C# type. If a matching column is supplied, uses
that column's C# type (stripped of its nullable suffix). Otherwise
falls back to name-based heuristics (*id → string,
limit/offset/count → int, everything else → object).
Parameters:
| Name | Type | Description |
|---|---|---|
paramName |
String |
The parameter name. |
columns |
DatabaseColumn> |
Optional columns to match against. |
Returns: String - A C# type literal for the parameter's method signature.