@@ -550,7 +550,7 @@ string outDir
550550 {
551551 Name = col . Name ,
552552 SqlType = col . Type . ToString ( ) ,
553- CSharpType = MapPostgresTypeToCSharp ( col . Type . ToString ( ) , col . IsNullable ) ,
553+ CSharpType = MapPortableTypeToCSharp ( col . Type , col . IsNullable ) ,
554554 IsNullable = col . IsNullable ,
555555 IsPrimaryKey = isPk ,
556556 IsIdentity = col . IsIdentity ,
@@ -1710,6 +1710,47 @@ List<string> parameters
17101710 return new Result < string , SqlError > . Ok < string , SqlError > ( sb . ToString ( ) ) ;
17111711 }
17121712
1713+ private static string MapPortableTypeToCSharp ( PortableType type , bool isNullable )
1714+ {
1715+ var baseType = type switch
1716+ {
1717+ UuidType => "Guid" ,
1718+ BooleanType => "bool" ,
1719+ SmallIntType => "short" ,
1720+ IntType => "int" ,
1721+ BigIntType => "long" ,
1722+ FloatType => "float" ,
1723+ DoubleType => "double" ,
1724+ DecimalType => "decimal" ,
1725+ MoneyType => "decimal" ,
1726+ SmallMoneyType => "decimal" ,
1727+ DateType => "DateOnly" ,
1728+ TimeType => "TimeOnly" ,
1729+ DateTimeType => "DateTime" ,
1730+ DateTimeOffsetType => "DateTimeOffset" ,
1731+ TextType => "string" ,
1732+ CharType => "string" ,
1733+ VarCharType => "string" ,
1734+ NCharType => "string" ,
1735+ NVarCharType => "string" ,
1736+ JsonType => "string" ,
1737+ XmlType => "string" ,
1738+ BinaryType => "byte[]" ,
1739+ VarBinaryType => "byte[]" ,
1740+ BlobType => "byte[]" ,
1741+ RowVersionType => "byte[]" ,
1742+ _ => "string" ,
1743+ } ;
1744+
1745+ // Add nullable suffix for nullable types (including strings but not arrays)
1746+ if ( isNullable && ! baseType . EndsWith ( "[]" , StringComparison . Ordinal ) )
1747+ {
1748+ return baseType + "?" ;
1749+ }
1750+
1751+ return baseType ;
1752+ }
1753+
17131754 private static string GetReaderExpression ( DatabaseColumn col , int ordinal )
17141755 {
17151756 var nullCheck = col . IsNullable ? $ "reader.IsDBNull({ ordinal } ) ? null : " : "" ;
0 commit comments