TypeMappingHelpers ​
Namespace: MJCZone.DapperMatic.Providers
Assembly: MJCZone.DapperMatic
Summary ​
Provides common helper methods for type mapping operations across all database providers.
static
public
Contents ​
Methods (37)
Methods ​
Method | Summary |
---|---|
GetAssemblyQualifiedShortName | Gets the short form assembly qualified name for a type (Type, Assembly). This is commonl... |
CreateDecimalType | Creates a SqlTypeDescriptor for decimal/numeric types with consistent precision and scale handling. |
CreateStringType | Creates a SqlTypeDescriptor for string/text types with consistent length and unicode handling. |
CreateGuidStringType | Creates a SqlTypeDescriptor for GUID types stored as strings. |
CreateEnumStringType | Creates a SqlTypeDescriptor for enum types stored as strings. |
IsNetTopologySuiteGeometryType | Determines if a type is a NetTopologySuite geometry type. |
GetGeometryTypeName | Gets the geometry type name from a NetTopologySuite type. |
CreateSimpleType | Creates a simple SqlTypeDescriptor for basic types without additional metadata. |
CreateDateTimeType | Creates a SqlTypeDescriptor for datetime types with optional precision. |
CreateBinaryType | Creates a SqlTypeDescriptor for binary types with length specification. |
CreateJsonType | Creates a SqlTypeDescriptor for JSON types, handling provider-specific variations. |
CreateGeometryType | Creates a SqlTypeDescriptor for geometry types based on geometry type name. |
CreateLobType | Creates a SqlTypeDescriptor for large object (LOB) types like text/blob. |
CreateArrayType | Creates a SqlTypeDescriptor for array types with element type information. |
CreatePrecisionType | Creates a SqlTypeDescriptor with precision-based length (for types like TIME, TIMESTAMP). |
IsArrayType | Determines if a .NET type represents an array type. |
GetArrayElementType | Gets the element type of an array type. |
IsGenericCollectionType | Determines if a .NET type is a generic collection type. |
GetCollectionElementType | Gets the element type of a generic collection. |
GetStandardGeometryTypes | Gets the standard NetTopologySuite geometry types for registration. This provides a cons... |
GetSqlServerGeometryTypes | Gets additional provider-specific geometry types for SQL Server. |
GetMySqlGeometryTypes | Gets additional provider-specific geometry types for MySQL. |
GetPostgreSqlSpecialTypes | Gets additional provider-specific geometry and network types for PostgreSQL. |
GetGeometryTypesForProvider | Gets the combined geometry types for a specific provider. |
GetStandardJsonTypes | Gets the standard System.Text.Json types that should be registered for JSON handling. Th... |
CreateJsonConverter | Creates a standardized JSON type converter for a specific provider. This handles the dif... |
CreateProviderOptimizedJsonType | Creates an enhanced JSON type descriptor with provider-specific optimizations. |
CreateNativeArrayType | Creates a native array type descriptor for PostgreSQL. |
CreateArrayConverter | Creates a standardized array converter that uses native arrays for PostgreSQL and falls ... |
GetPostgreSqlArrayTypeName | Maps .NET array element types to PostgreSQL array type names. |
SupportsNativeArrays | Determines if a provider supports native array types. |
GetPostgreSqlStandardArrayTypes | Gets the standard PostgreSQL array type names that should be registered for SQL-to-.NET type mapping... |
CreatePostgreSqlArrayTypeConverter | Creates a SQL-to-.NET array type converter for PostgreSQL that converts array types to their .NET ar... |
GetType | |
ToString | |
Equals | |
GetHashCode |
GetAssemblyQualifiedShortName ​
Gets the short form assembly qualified name for a type (Type, Assembly). This is commonly used for geometry type identification.
string? GetAssemblyQualifiedShortName(Type type)
Parameters ​
- type (Type) - The type to get the short assembly qualified name for.
Returns ​
Type: string?
The short assembly qualified name in format "FullTypeName, AssemblyName" or null if type is null.
CreateDecimalType ​
Creates a SqlTypeDescriptor for decimal/numeric types with consistent precision and scale handling.
SqlTypeDescriptor CreateDecimalType(string sqlType, Int32} precision, Int32} scale)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "decimal", "numeric").
- precision (Int32}) - The precision, or null to use default.
- scale (Int32}) - The scale, or null to use default.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor with properly formatted SQL type name and metadata.
CreateStringType ​
Creates a SqlTypeDescriptor for string/text types with consistent length and unicode handling.
SqlTypeDescriptor CreateStringType(string sqlType, Int32} length, bool isUnicode, bool isFixedLength)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "varchar", "nvarchar", "char").
- length (Int32}) - The length, or null to use default.
- isUnicode (bool) - Whether the type supports unicode characters.
- isFixedLength (bool) - Whether the type is fixed-length.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor with properly formatted SQL type name and metadata.
CreateGuidStringType ​
Creates a SqlTypeDescriptor for GUID types stored as strings.
SqlTypeDescriptor CreateGuidStringType(string sqlType, bool isUnicode, bool isFixedLength)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "varchar", "char").
- isUnicode (bool) - Whether the type supports unicode characters.
- isFixedLength (bool) - Whether the type is fixed-length (typically true for GUIDs).
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for GUID storage.
CreateEnumStringType ​
Creates a SqlTypeDescriptor for enum types stored as strings.
SqlTypeDescriptor CreateEnumStringType(string sqlType, bool isUnicode)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "varchar").
- isUnicode (bool) - Whether the type supports unicode characters.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for enum storage.
IsNetTopologySuiteGeometryType ​
Determines if a type is a NetTopologySuite geometry type.
bool? IsNetTopologySuiteGeometryType(Type type)
Parameters ​
- type (Type) - The type to check.
Returns ​
Type: bool?
True if the type is a NetTopologySuite geometry type.
GetGeometryTypeName ​
Gets the geometry type name from a NetTopologySuite type.
string? GetGeometryTypeName(Type type)
Parameters ​
- type (Type) - The NetTopologySuite geometry type.
Returns ​
Type: string?
The geometry type name (e.g., "Point", "LineString", "Polygon") or null if not a geometry type.
CreateSimpleType ​
Creates a simple SqlTypeDescriptor for basic types without additional metadata.
SqlTypeDescriptor CreateSimpleType(string sqlType)
Parameters ​
- sqlType (string) - The SQL type name.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor for the basic type.
CreateDateTimeType ​
Creates a SqlTypeDescriptor for datetime types with optional precision.
SqlTypeDescriptor CreateDateTimeType(string sqlType, Int32} precision)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "datetime", "timestamp").
- precision (Int32}) - The precision for fractional seconds, or null for no precision.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor with properly formatted SQL type name and metadata.
CreateBinaryType ​
Creates a SqlTypeDescriptor for binary types with length specification.
SqlTypeDescriptor CreateBinaryType(string sqlType, Int32} length, bool isFixedLength)
Parameters ​
- sqlType (string) - The base SQL type name (e.g., "binary", "varbinary").
- length (Int32}) - The length, or null to use default.
- isFixedLength (bool) - Whether the type is fixed-length.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for binary storage.
CreateJsonType ​
Creates a SqlTypeDescriptor for JSON types, handling provider-specific variations.
SqlTypeDescriptor CreateJsonType(string sqlType, bool isText)
Parameters ​
- sqlType (string) - The SQL type for JSON storage (e.g., "json", "jsonb", "nvarchar(max)").
- isText (bool) - Whether this is stored as text (true) or native JSON (false).
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for JSON storage.
CreateGeometryType ​
Creates a SqlTypeDescriptor for geometry types based on geometry type name.
SqlTypeDescriptor CreateGeometryType(string sqlType, string geometryTypeName)
Parameters ​
- sqlType (string) - The SQL type for geometry storage (e.g., "geometry", "geography").
- geometryTypeName (string) - The specific geometry type name (e.g., "Point", "Polygon").
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for geometry storage.
CreateLobType ​
Creates a SqlTypeDescriptor for large object (LOB) types like text/blob.
SqlTypeDescriptor CreateLobType(string sqlType, bool isUnicode)
Parameters ​
- sqlType (string) - The SQL type for LOB storage (e.g., "text", "blob", "longtext").
- isUnicode (bool) - Whether the LOB supports unicode characters (for text LOBs).
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for LOB storage.
CreateArrayType ​
Creates a SqlTypeDescriptor for array types with element type information.
SqlTypeDescriptor CreateArrayType(string sqlType, string elementTypeName)
Parameters ​
- sqlType (string) - The SQL type for array storage (e.g., "integer[]", "text[]").
- elementTypeName (string) - The name of the element type (e.g., "integer", "text").
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for array storage.
CreatePrecisionType ​
Creates a SqlTypeDescriptor with precision-based length (for types like TIME, TIMESTAMP).
SqlTypeDescriptor CreatePrecisionType(string sqlType, int precision)
Parameters ​
- sqlType (string) - The base SQL type name.
- precision (int) - The precision value.
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor with precision formatting.
IsArrayType ​
Determines if a .NET type represents an array type.
bool? IsArrayType(Type type)
Parameters ​
- type (Type) - The type to check.
Returns ​
Type: bool?
True if the type is an array type.
GetArrayElementType ​
Gets the element type of an array type.
Type? GetArrayElementType(Type arrayType)
Parameters ​
- arrayType (Type) - The array type.
Returns ​
Type: Type?
The element type, or null if not an array type.
IsGenericCollectionType ​
Determines if a .NET type is a generic collection type.
bool? IsGenericCollectionType(Type type)
Parameters ​
- type (Type) - The type to check.
Returns ​
Type: bool?
True if the type is a generic collection.
GetCollectionElementType ​
Gets the element type of a generic collection.
Type? GetCollectionElementType(Type collectionType)
Parameters ​
- collectionType (Type) - The collection type.
Returns ​
Type: Type?
The element type, or null if not a supported collection type.
GetStandardGeometryTypes ​
Gets the standard NetTopologySuite geometry types for registration. This provides a consistent set of geometry types across all providers.
Type[] GetStandardGeometryTypes()
Returns ​
Type: Type[]
An array of NetTopologySuite geometry types, filtering out null entries.
GetSqlServerGeometryTypes ​
Gets additional provider-specific geometry types for SQL Server.
Type[] GetSqlServerGeometryTypes()
Returns ​
Type: Type[]
An array of SQL Server specific geometry types, filtering out null entries.
GetMySqlGeometryTypes ​
Gets additional provider-specific geometry types for MySQL.
Type[] GetMySqlGeometryTypes()
Returns ​
Type: Type[]
An array of MySQL specific geometry types, filtering out null entries.
GetPostgreSqlSpecialTypes ​
Gets additional provider-specific geometry and network types for PostgreSQL.
Type[] GetPostgreSqlSpecialTypes()
Returns ​
Type: Type[]
An array of PostgreSQL specific types, filtering out null entries.
GetGeometryTypesForProvider ​
Gets the combined geometry types for a specific provider.
Type[] GetGeometryTypesForProvider(string provider)
Parameters ​
- provider (string) - The database provider name.
Returns ​
Type: Type[]
An array of all geometry types for the specified provider.
GetStandardJsonTypes ​
Gets the standard System.Text.Json types that should be registered for JSON handling. This provides a consistent set of JSON types across all providers.
Type[] GetStandardJsonTypes()
Returns ​
Type: Type[]
An array of System.Text.Json types.
CreateJsonConverter ​
Creates a standardized JSON type converter for a specific provider. This handles the different JSON storage strategies across providers. Note: This method should be used by individual providers who can provide their specific type constants.
DotnetTypeToSqlTypeConverter CreateJsonConverter(string provider)
Parameters ​
- provider (string) - The database provider name.
Returns ​
Type: DotnetTypeToSqlTypeConverter
A DotnetTypeToSqlTypeConverter configured for the provider's JSON strategy.
CreateProviderOptimizedJsonType ​
Creates an enhanced JSON type descriptor with provider-specific optimizations.
SqlTypeDescriptor CreateProviderOptimizedJsonType(string provider, bool isUnicode)
Parameters ​
- provider (string) - The database provider name.
- isUnicode (bool) - Whether to use Unicode storage for text-based JSON (relevant for SQL Server/SQLite).
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor optimized for the provider's JSON capabilities.
CreateNativeArrayType ​
Creates a native array type descriptor for PostgreSQL.
SqlTypeDescriptor CreateNativeArrayType(string elementSqlType)
Parameters ​
- elementSqlType (string) - The SQL type of the array element (e.g., "integer", "text").
Returns ​
Type: SqlTypeDescriptor
A SqlTypeDescriptor configured for PostgreSQL native array storage.
CreateArrayConverter ​
Creates a standardized array converter that uses native arrays for PostgreSQL and falls back to JSON for other providers.
DotnetTypeToSqlTypeConverter CreateArrayConverter(string provider)
Parameters ​
- provider (string) - The database provider name.
Returns ​
Type: DotnetTypeToSqlTypeConverter
A DotnetTypeToSqlTypeConverter configured for the provider's array strategy.
GetPostgreSqlArrayTypeName ​
Maps .NET array element types to PostgreSQL array type names.
string? GetPostgreSqlArrayTypeName(Type elementType)
Parameters ​
- elementType (Type) - The .NET element type.
Returns ​
Type: string?
The PostgreSQL array type name, or null if not supported.
SupportsNativeArrays ​
Determines if a provider supports native array types.
bool SupportsNativeArrays(string provider)
Parameters ​
- provider (string) - The database provider name.
Returns ​
Type: bool
True if the provider supports native arrays.
GetPostgreSqlStandardArrayTypes ​
Gets the standard PostgreSQL array type names that should be registered for SQL-to-.NET type mapping. This provides array versions of common PostgreSQL types.
string[] GetPostgreSqlStandardArrayTypes()
Returns ​
Type: string[]
An array of PostgreSQL array type names.
CreatePostgreSqlArrayTypeConverter ​
Creates a SQL-to-.NET array type converter for PostgreSQL that converts array types to their .NET array equivalents.
SqlTypeToDotnetTypeConverter CreatePostgreSqlArrayTypeConverter()
Returns ​
Type: SqlTypeToDotnetTypeConverter
A SqlTypeToDotnetTypeConverter configured for PostgreSQL array types.
GetType ​
void GetType()
ToString ​
void ToString()
Equals ​
void Equals()
GetHashCode ​
void GetHashCode()