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 |
CSDL .NET |
|
---|---|---|---|
boolean | Boolean | System.Boolean | |
smallint,int2 | smallint | Int16 | System.Int16 |
integer,int4 | int | Int32 | System.Int32 |
bigint,int8 | bigint | Int64 | System.Int64 |
real | Single | System.Single | |
double precision,money | double precision | Double | System.Double |
numeric,decimal,float | Decimal | System.Decimal | |
date,timestamp,timestamp with time zone,timestamp without time zone | DateTime | System.DateTime | |
time,time with time zone,time without time zone,interval | Time | System.TimeSpan | |
timestamp with time zone | datetimeoffset | DateTimeOffset | System.DateTimeOffset |
char,varchar,text,citext,enum,bit,varbit,cidr,inet,macaddr,point,line,lseg,box,path,polygon,circle,xml*,character,character varying,bit varying,json,jsonb | String | System.String | |
bytea | Binary | System.Byte[] | |
uuid2 | uuid | Guid | System.Guid |
geometry3 | spatial_geometry | Geometry,GeometryCollection,GeometryLinestring,GeometryMultiLinestring,GeometryMultiPoint,GeometryMultipolygon,GeometryPoint,Geometrypolygon | System.Data.Spatial.DbGeometry |
geography spatial_geography | Geography,GeographyCollection,GeographyLineString,GeographyMultiLineString,GeographyMultiPoint,GeographyMultiPolygon,GeographyPoint,GeographyPolygon | System.Data.Spatial.DbGeography |
1Note 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.
2Uuid and xml data types appeared in Postgresql 8.3.
3Supported in Entity Framework v5 and v6.
.NET to Postgresql default type mapping
.NET |
||||
---|---|---|---|---|
System.Boolean | boolean | |||
System.Byte | Byte | byte | smallint | |
System.Byte[] | bytea | |||
System.Data.Spatial.DbGeometry Geometry | geometry | |||
System.Data.Spatial.DbGeography Geography | geography | |||
System.DateTime | timestamp | timestamp | ||
System.DateTimeOffset | timestamp with time zone | |||
System.Decimal | numeric | numeric | ||
System.Double | double precision | |||
System.Guid | uuid | |||
System.Int16 | System.Int32 | integer | ||
System.Int64 | bigint | |||
System.SByte | SByte | sbyte | System.Single | real |
System.String | ||||
System.TimeSpan | timestamp |
2Supported in Entity Framework v5 and v6.
DateTimeOffcet type is not supported.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。