標籤:-- 行業 屬性 pch ica cond post point poi
PostgreSQL type |
預設的 .NET 類型 |
特定提供的類型 |
其他 .NET 類型 |
bool |
bool |
|
|
int2 |
short |
|
byte, sbyte, int, long, float, double, decimal, string |
int4 |
int |
|
byte, short, long, float, double, decimal, string |
int8 |
long |
|
long, byte, short, int, float, double, decimal, string |
float4 |
float |
|
double |
float8 |
double |
|
|
numeric |
decimal |
|
byte, short, int, long, float, double, string |
money |
decimal |
|
|
text |
string |
|
char[] |
varchar |
string |
|
char[] |
bpchar |
string |
|
char[] |
citext |
string |
|
char[] |
json |
string |
|
char[] |
jsonb |
string |
|
char[] |
xml |
string |
|
char[] |
point |
NpgsqlPoint |
|
string |
lseg |
NpgsqlLSeg |
|
string |
path |
NpgsqlPath |
|
|
polygon |
NpgsqlPolygon |
|
|
line |
NpgsqlLine |
|
string |
circle |
NpgsqlCircle |
|
string |
box |
NpgsqlBox |
|
string |
bit(1) |
bool |
|
BitArray |
bit(n) |
BitArray |
|
|
varbit |
BitArray |
|
|
hstore |
IDictionary<string, string=""> |
|
string |
uuid |
Guid |
|
string |
cidr |
NpgsqlInet |
|
string |
inet |
IPAddress |
NpgsqlInet |
string |
macaddr |
PhysicalAddress |
|
string |
tsquery |
NpgsqlTsQuery |
|
|
tsvector |
NpgsqlTsVector |
|
|
date |
DateTime |
NpgsqlDate |
|
interval |
TimeSpan |
NpgsqlTimeSpan |
|
timestamp |
DateTime |
NpgsqlDateTime |
|
timestamptz |
DateTime |
NpgsqlDateTime |
DateTimeOffset |
time |
TimeSpan |
|
|
timetz |
DateTimeOffset |
|
DateTimeOffset, DateTime, TimeSpan |
bytea |
byte[] |
|
|
oid |
uint |
|
|
xid |
uint |
|
|
cid |
uint |
|
|
oidvector |
uint[] |
|
|
name |
string |
|
char[] |
(internal) char |
char |
|
byte, short, int, long |
geometry (PostGIS) |
PostgisGeometry |
|
|
record |
object[] |
|
|
composite types |
T |
|
|
range subtypes |
NpgsqlRange |
|
|
enum types |
TEnum |
|
|
array types |
Array (of child element type) |
|
|
向後端發送參數時的類型映射
有三個規則,確定PostgreSQL類型發送一個參數:
1,如果設定了參數的NpgsqlDbType,使用它。
2,如果設定了參數的DbType,就會使用它。
3,如果以上兩個都沒有設定,那麼後端類型將從CLR實值型別推斷出來。
注意,DateTime和NpgsqlDateTime,屬性決定是否使用時間戳或timestamptz。
注意,當NpgsqlDbType或DbType設定為一個原始類型(布爾值、數字和字串),其他基本類型是接受因為他們都實現IConvertible介面,這就是Npgsql使用價值目標類型轉換。
NpgsqlDbType |
DbType |
PostgreSQL type |
接受的 .NET 資料類型 |
Boolean |
Boolean |
bool |
bool, IConvertible |
Smallint |
Int16 |
int2 |
short, IConvertible |
Integer |
Int32 |
int4 |
int, IConvertible |
Bigint |
Int64 |
int8 |
long, IConvertible |
Real |
Single |
float4 |
float, IConvertible |
Double |
Double |
float8 |
double, IConvertible |
Numeric |
Decimal, VarNumeric |
numeric |
decimal, IConvertible |
Money |
Currency |
money |
decimal, IConvertible |
Text |
String, StringFixedLength, AnsiString, AnsiStringFixedLength |
text |
string, char[], char, IConvertible |
Varchar |
|
varchar |
string, char[], char, IConvertible |
Char |
|
char |
string, char[], char, IConvertible |
Citext |
|
citext |
string, char[], char, IConvertible |
Json |
|
json |
string, char[], char, IConvertible |
Jsonb |
|
jsonb |
string, char[], char, IConvertible |
Xml |
|
xml |
string, char[], char, IConvertible |
Point |
|
point |
NpgsqlPoint |
LSeg |
|
lseg |
NpgsqlLSeg |
Path |
|
path |
NpgsqlPath |
Polygon |
|
polygon |
NpgsqlPolygon |
Line |
|
line |
NpgsqlLine |
Circle |
|
circle |
NpgsqlCircle |
Box |
|
box |
NpgsqlBox |
Bit |
|
bit |
BitArray, bool, string |
Varbit |
|
varbit |
BitArray, bool, string |
Hstore |
|
hstore |
IDictionary<string, string=""> |
Uuid |
|
uuid |
Guid, string |
Cidr |
|
cidr |
IPAddress, NpgsqlInet |
Inet |
|
inet |
IPAddress, NpgsqlInet |
MacAddr |
|
macaddr |
PhysicalAddress |
TsQuery |
|
tsquery |
NpgsqlTsQuery |
TsVector |
|
tsvector |
NpgsqlTsVector |
Date |
Date |
date |
DateTime, NpgsqlDate, IConvertible |
Interval |
|
interval |
TimeSpan, NpgsqlTimeSpan, string |
Timestamp |
DateTime, DateTime2 |
timestamp |
DateTime, DateTimeOffset, NpgsqlDateTime, IConvertible |
TimestampTZ |
DateTimeOffset |
timestamptz |
DateTime, DateTimeOffset, NpgsqlDateTime, IConvertible |
Time |
Time |
time |
TimeSpan, string |
TimeTZ |
|
timetz |
DateTimeOffset, DateTime, TimeSpan |
Bytea |
Binary |
bytea |
byte[], ArraySegment |
Oid |
|
oid |
uint, IConvertible |
Xid |
|
xid |
uint, IConvertible |
Cid |
|
cid |
uint, IConvertible |
Oidvector |
|
oidvector |
uint[] |
Name |
|
name |
string, char[], char, IConvertible |
InternalChar |
|
(internal) char |
byte, IConvertible |
Geometry |
|
geometry |
PostgisGeometry |
Composite |
|
composite types |
T |
Range | (other NpgsqlDbType) |
|
range types |
NpgsqlRange |
Enum |
|
enum types |
TEnum |
Array | (other NpgsqlDbType) |
|
array types |
Array, IList, IList |
自從mysql被收購狗,postgresql這個關係型資料庫已經成為福士IT行業認養的首選。
我自己被這個裡面的部分類型在.NET映射時弄的暈頭轉向。現在在國外網站找到這個對照類型表,供大家參考。
-----------------------------------------禁止轉載!!!---------------------------------------------------
postgresql 和.NET類型對照表