PostgreSQL and. NET Type comparison tables

Source: Internet
Author: User
Tags postgresql uuid

PostgreSQL Type the default. NET type specific types of offers 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)

Type mappings when sending parameters to the back end

There are three rules that determine the PostgreSQL type to send a parameter:

1, if you set the Npgsqldbtype of the parameter, use it.

2, if you set the DbType of the parameter, it will be used.

3, if none of the above two are set, then the backend type is inferred from the CLR value type.

Note that datetime and Npgsqldatetime properties determine whether a timestamp or TIMESTAMPTZ is used.

Note that when Npgsqldbtype or DbType is set to an original type (Boolean, number, and string), the other base types are accepted because they all implement the IConvertible interface, which is the Npgsql use value target type conversion.

Npgsqldbtype DbType PostgreSQL Type accepted. NET Data Types
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

Since MySQL was acquired by the dog, PostgreSQL's relational database has become the preferred choice for the public IT industry to adopt.

I myself was in this part of the type. NET mapping is confusing. Now on the foreign website to find this control type table for your reference.

-----------------------------------------prohibited reprint!!! ---------------------------------------------------

PostgreSQL and. NET Type comparison tables

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.