2009-05-10 17 views
38

Ho cercato la tabella di conversione dei tipi tra PostgreSQL e C#, ma non ho trovato nulla. Cercherò una cella vuota sopra il tavolo se avrò tempo. Ma se conosci la pagina web che contiene queste informazioni, sono molto adatto al tuo aiuto.Datatype PostgreSQL e C#

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 

risposta

77

Forse si può trovare qualcosa guardando attraverso la documentazione di Npgsql, che è un'implementazione di un provider di dati .NET per PostgreSQL.

This page of the documentation contiene in realtà una tabella completa di ciò che stai cercando. Cerca "4. Current Npgsql Status" - "Tipi di dati supportati". C'è una bella tabella con tutti i tipi di dati PostgreSQL e i loro corrispondenti in .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

Oh grazie mille e la tua rapida risposta. Questo è proprio quello che voglio !! – Higty

+0

Prego! – splattne

+1

Non sono sicuro se questa data è scaduta, ma ho avuto alcuni problemi nel far convertire un oggetto DateTime in un tipo "time" Postgresql. http://stackoverflow.com/questions/6129558/nhibernate-postgresql-datetime-to-time-conversion/6138382. Avevo bisogno di usare un oggetto TimeSpan per farlo salvare come oggetto orario Postgresql. –