Npgsql 是基于ADO.NET 的PostgreSQL 数据驱动。
Npgsql 官方 已经提供C# 数据类型与PostgreSQL数据类型的对应映射
地址: http://www.npgsql.org/doc/types.html
Type mappings
Type mappings when reading values sent from the backend
PostgreSQL type | Default .NET type | Provider-specific type | Other .NET types |
---|---|---|---|
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) | |
有需要的朋友可以去看看。