PostgreSQL 和 C# 数据类型 [英] PostgreSQL and C# Datatypes

查看:32
本文介绍了PostgreSQL 和 C# 数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了 PostgreSQL 和 C# 之间的类型转换表,但找不到任何内容.如果我有时间,我会研究上表中的空单元格.但是如果你知道有这些信息的网页,我非常适合你的帮助.

Postgre 类型 ---> C# 类型bigint ---> Int64bigserial --->位 [ (n) ] ---> 字节 []位变化 [ (n) ] ---> 字节布尔值 ---> 布尔值框 --->bytea ---> 字节[]字符变化 [ (n) ] --->细绳字符 ---> 字符串苹果酒圆圈日期 ---> 日期时间双精度--->双内网整数 ---> Int32间隔 [ (p) ] ---> TimeSpan线lsegmac地址钱数字 [ (p, s) ] ---> 十进制十进制 [ (p, s) ] ---> 十进制小路观点多边形真实的--->单身smallint ---> Int16连续剧文本 ---> 字符串时间 [ (p) ] [ 不带时区 ] --->时间 [ (p) ] 带时区 --->时间戳 [ (p) ] [ 不带时区 ] --->时间戳 [ (p) ] 带时区 --->查询向量txid_snapshotuuid ---> 向导xml

解决方案

也许你可以通过查看Npgsql,它是 PostgreSQL 的 .NET 数据提供程序的实现.

文档的这一页实际上包含一个完整的表格,说明您的身份寻找.搜索4. 当前 Npgsql 状态"-支持的数据类型".有一个很好的表格,其中包含所有 PostgreSQL 数据类型及其在 .NET 中的对应关系.

<前>Postgresql NpgsqlDbType System.DbType Enum .Net 系统类型---------- ---------- ---------- ----------------int8 Bigint Int64 Int64bool 布尔 布尔 布尔bytea 字节字节二进制字节[]日期日期日期日期时间float8 双双双int4 整数 Int32 Int32钱 钱 十进制 十进制数字 数字 十进制 十进制float4 实单单int2 Smallint Int16 Int16文本 文本 字符串 字符串时间 时间 时间 日期时间timetz 时间 时间 日期时间时间戳 时间戳 日期时间 日期时间timestamptz TimestampTZ DateTime DateTime间隔 间隔 对象 TimeSpanvarchar Varchar 字符串 字符串inet Inet 对象 IP 地址位 位 布尔 布尔uuid Uuid 向导指南数组 数组 对象 数组

I searched type convertion table between PostgreSQL and C#, but I couldn't find anything. I'll research empty cell on above table if I have time. But if you know the web page which has these information, I'm very appropriate to your help.

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   

解决方案

Maybe you can find something looking through the documentation of Npgsql, which is an implementation of a .NET Data Provider for PostgreSQL.

This page of the documentation actually contains a complete table of what you are looking for. Search for "4. Current Npgsql Status" - "Supported data types". There is a nice table with all PostgreSQL data types and their correspondents 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

这篇关于PostgreSQL 和 C# 数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆