Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL and C# Datatypes

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    
like image 832
Higty Avatar asked May 10 '09 14:05

Higty


People also ask

What is C in PostgreSQL?

libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.

How do I connect to PostgreSQL from C++?

Here, dbstring provides required parameters to connect to the datbase, for example dbname = testdb user = postgres password=pass123 hostaddr=127.0. 0.1 port=5432. If connection is setup successfully then it creates C with connection object which provides various useful function public function.

Does PostgreSQL support C#?

It is a specification that unifies access to relational databases, XML files and other application data. Npgsql is an implementation of the ADO.NET specification for the PostgreSQL database. It is a driver written in C# language and is available for all .


1 Answers

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 
like image 52
splattne Avatar answered Oct 09 '22 01:10

splattne