PostgreSQL and C# Datatypes

C#PostgresqlTypes

C# Problem Overview


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   

C# Solutions


Solution 1 - C#

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHigtyView Question on Stackoverflow
Solution 1 - C#splattneView Answer on Stackoverflow