The data types available for SQL data types are as follows:
List of data types belonging to base data types
Data types belonging to these base data types are supported whether you automatically generate applications using tools in Visual Studio (Query Builder in TableAdapter and Server Explorer), or create applications yourself (with Data Provider).
SQL data types | Npgsql | |
---|---|---|
Data type | .NET CLS data type | |
character | NpgsqlDbType.Char | System.String |
character varying | NpgsqlDbType.Varchar | System.String |
national character | NpgsqlDbType.NChar | System.String |
national character varying | NpgsqlDbType.NVarchar | System.String |
text | NpgsqlDbType.Text | System.String |
bytea | NpgsqlDbType.Bytea | System.Byte[] |
smallint | NpgsqlDbType.Smallint | System.Int16 |
integer | NpgsqlDbType.Integer | System.Int32 |
bigint | NpgsqlDbType.Bigint | System.Int64 |
smallserial | NpgsqlDbType.Smallint | System.Int16 |
serial | NpgsqlDbType.Integer | System.Int32 |
bigserial | NpgsqlDbType.Bigint | System.Int64 |
real | NpgsqlDbType.Real | System.Single |
double precision | NpgsqlDbType.Double | System.Double |
numeric | NpgsqlDbType.Numeric | System.Decimal |
decimal | NpgsqlDbType.Numeric | System.Decimal |
date | NpgsqlDbType.Date | System.DateTime |
NpgsqlTypes.NpgsqlDate | ||
time with time zone | NpgsqlDbType.TimeTZ | System.DateTimeOffset |
NpgsqlTypes.NpgsqlTimeTZ | ||
time without time zone | NpgsqlDbType.Time | System.DateTime |
NpgsqlTypes.NpgsqlTime | ||
timestamp without time zone | NpgsqlDbType.Timestamp | System.DateTime |
NpgsqlTypes.NpgsqlTimeStamp | ||
timestamp with time zone | NpgsqlDbType.TimestampTZ | System.DateTime |
NpgsqlTypes.NpgsqlTimeStampTZ | ||
interval | NpgsqlDbType.Interval | System.String/System.TimeSpan(*1) |
boolean | NpgsqlDbType.Boolean | System.Boolean |
bit | NpgsqlDbType.Bit | System.Boolean |
NpgsqlTypes.BitString | ||
uuid | NpgsqlDbType.Uuid | System.Guid |
inet | NpgsqlDbType.Inet | NpgsqlTypes.NpgsqlInet |
System.Net.IPAddress | ||
macaddr | NpgsqlDbType.MacAddr | NpgsqlTypes.NpgsqlMacAddress |
System.Net.NetworkInformation.PhysicalAddress | ||
box | NpgsqlDbType.Box | NpgsqlTypes.NpgsqlBox |
circle | NpgsqlDbType.Circle | NpgsqlTypes.NpgsqlCircle |
lseg | NpgsqlDbType.LSeg | NpgsqlTypes.NpgsqlLSeg |
path | NpgsqlDbType.Path | NpgsqlTypes.NpgsqlPath |
point | NpgsqlDbType.Point | NpgsqlTypes.NpgsqlPoint |
polygon | NpgsqlDbType.Polygon | NpgsqlTypes.NpgsqlPolygon |
array | NpgsqlDbType.Array | System.Array |
*1: The .NET CLS data types that can be used vary depending on the SQL interval type.
If using interval year/interval month/interval year to month, use System.String.
For other data types, use System.TimeSpan.