PostgreSQL to .NET type mapping

来源:互联网 发布:python 爬虫 定时任务 编辑:程序博客网 时间:2024/06/05 07:33

PostgreSQL to .NET type mapping

Type mapping rules from this table are used when generating a model from a database with Entity Data Model Wizard in Visual Studio 2008 - 2015 and Create Model Wizard in Entity Developer.

PostgreSQL data types

SSDL1

CSDL1

.NET

booleanbooleanBooleanSystem.Booleansmallint, int2smallintInt16System.Int16integer, int4intInt32System.Int32bigint, int8bigintInt64System.Int64realrealSingleSystem.Singledouble precision, moneydouble precisionDoubleSystem.Doublenumeric, decimal, floatnumeric, decimal, floatDecimalSystem.Decimaldate, timestamp, timestamp with time zone, timestamp without time zonedate, timestamp, timestamptzDateTimeSystem.DateTimetime, time with time zone, time without time zone, intervaltime, timetz, intervalTimeSystem.TimeSpantimestamp with time zonedatetimeoffsetDateTimeOffsetSystem.DateTimeOffsetchar, varchar, text, citext, enum, bit, varbit, cidr, inet, macaddr, point, line, lseg, box, path, polygon, circle, xml*, character, character varying, bit varying, json, jsonbchar, varchar, text, enum, bit, varbit, cidr, inet, macaddr, point, line, lseg, box, path, polygon, circle, xml, json, jsonbStringSystem.StringbyteabyteaBinarySystem.Byte[]uuid2uuidGuidSystem.Guidgeometry3spatial_geometryGeometry, GeometryCollection, GeometryLineString, GeometryMultiLineString, GeometryMultiPoint, GeometryMultiPolygon, GeometryPoint, GeometryPolygonSystem.Data.Spatial.DbGeometrygeography3spatial_geographyGeography, GeographyCollection, GeographyLineString, GeographyMultiLineString, GeographyMultiPoint, GeographyMultiPolygon, GeographyPoint, GeographyPolygonSystem.Data.Spatial.DbGeography

1 Note that when mapping corresponding database data type, you will need the .NET type with larger precision. That is because, for example, any Int32 value can be stored in the NUMBER(10) column, but largest NUMBER(10) column value cannot be stored in the Int32 field, it requires Int64 field.

2 Uuid and xml data types appeared in PostgreSQL 8.3.

3 Supported in Entity Framework v5 and v6.

.NET to PostgreSQL default type mapping

.NET

CSDL1

SSDL1

PostgreSQL data types

System.BooleanBooleanbooleanbooleanSystem.ByteBytebytesmallintSystem.Byte[]BinarybyteabyteaSystem.Data.Spatial.DbGeometry2Geometryspatial_geometrygeometrySystem.Data.Spatial.DbGeography2Geographyspatial_geographygeographySystem.DateTimeDateTimetimestamptimestampSystem.DateTimeOffsetDateTimeOffsetdatetimeoffsettimestamp with time zoneSystem.DecimalDecimalnumericnumericSystem.DoubleDoubledouble precisiondouble precisionSystem.GuidGuiduuiduuidSystem.Int16Int16smallintsmallintSystem.Int32Int32intintegerSystem.Int64Int64bigintbigintSystem.SByteSBytesbytesmallintSystem.SingleSinglerealrealSystem.StringStringchar, varcharchar, varcharSystem.TimeSpanTimetimestamptimestamp

1 Note that when mapping corresponding database data type, you will need the .NET type with larger precision. That is because, for example, any Int32 value can be stored in the NUMBER(10) column, but largest NUMBER(10) column value cannot be stored in the Int32 field, it requires Int64 field.

2 Supported in Entity Framework v5 and v6.

DateTimeOffcet type is not supported.

 

0 0