2009-05-10 22 views
38

Busqué una tabla de conversión de tipo entre PostgreSQL y C#, pero no pude encontrar nada. Investigaré la celda vacía en la tabla de arriba si tengo tiempo. Pero si conoce la página web que tiene esta información, soy muy apropiado para su ayuda.PostgreSQL y C# Datatypes

Postgre Type --->C# Type 

bigint --->Int64 

bigserial ---> 

bit [ (n) ] --->Byte[] 

bit varying [ (n) ] --->Byte 

boolean --->Boolean 

box ---> 

bytea --->Byte[] 

character varying [ (n) ] ---> String 

character --->String 

cidr 

circle 

date --->DateTime 

double precision --->Double 

inet 

integer --->Int32 

interval [ (p) ] --->TimeSpan 

line 

lseg 

macaddr 

money 

numeric [ (p, s) ] --->Decimal 

decimal [ (p, s) ] --->Decimal 

path 

point 

polygon 

real --->Single 

smallint --->Int16 

serial 

text --->String 

time [ (p) ] [ without time zone ] ---> 

time [ (p) ] with time zone ---> 

timestamp [ (p) ] [ without time zone ] ---> 

timestamp [ (p) ] with time zone ---> 

tsquery 

tsvector 

txid_snapshot 

uuid --->Guid 

xml 

Respuesta

77

Tal vez se puede encontrar algo mirando a través de la documentación de Npgsql, que es una implementación de un proveedor de datos .NET para PostgreSQL.

This page of the documentation en realidad contiene una tabla completa de lo que estás buscando. Busque "4. Estado actual de Npgsql" - "Tipos de datos admitidos". Hay una buena tabla con todos los tipos de datos PostgreSQL y sus correspondientes en .NET.

 
Postgresql NpgsqlDbType System.DbType Enum .Net System Type 
---------- ------------ ------------------ ---------------- 
int8  Bigint  Int64    Int64 
bool  Boolean  Boolean   Boolean 
bytea  Bytea  Binary    Byte[] 
date  Date   Date    DateTime 
float8  Double  Double    Double 
int4  Integer  Int32    Int32 
money  Money  Decimal   Decimal 
numeric  Numeric  Decimal   Decimal 
float4  Real   Single    Single 
int2  Smallint  Int16    Int16 
text  Text   String    String 
time  Time   Time    DateTime 
timetz  Time   Time    DateTime 
timestamp Timestamp DateTime   DateTime 
timestamptz TimestampTZ DateTime   DateTime 
interval Interval  Object    TimeSpan 
varchar  Varchar  String    String 
inet  Inet   Object    IPAddress 
bit   Bit   Boolean   Boolean 
uuid  Uuid   Guid    Guid 
array  Array  Object    Array 
+1

Muchas gracias y su respuesta rápida. ¡Eso es justo lo que quiero! – Higty

+0

¡De nada! – splattne

+1

No estoy seguro de si esto está desactualizado, pero tuve algunos problemas para obtener un objeto DateTime para convertirlo a un tipo de "hora" de Postgresql. http://stackoverflow.com/questions/6129558/nhibernate-postgresql-datetime-to-time-conversion/6138382. Necesitaba usar un objeto TimeSpan para hacer que se guarde como un objeto de tiempo Postgresql. –