Table of Contents

Class PostgreSqlDataType

Namespace
LfrlAnvil.PostgreSql
Assembly
LfrlAnvil.PostgreSql.dll

Represents a DB data type.

public sealed class PostgreSqlDataType : ISqlDataType, IEquatable<PostgreSqlDataType>, IComparable<PostgreSqlDataType>, IComparable
Inheritance
PostgreSqlDataType
Implements
Inherited Members

Remarks

PostgreSqlDialect implementation.

Fields

Boolean

Represents the BOOLEAN type.

public static readonly PostgreSqlDataType Boolean

Field Value

PostgreSqlDataType

Bytea

Represents the BYTEA type.

public static readonly PostgreSqlDataType Bytea

Field Value

PostgreSqlDataType

Date

Represents the DATE type.

public static readonly PostgreSqlDataType Date

Field Value

PostgreSqlDataType

Decimal

Represents the DECIMAL type with default 29 scale and 10 precision.

public static readonly PostgreSqlDataType Decimal

Field Value

PostgreSqlDataType

Float4

Represents the FLOAT4 type.

public static readonly PostgreSqlDataType Float4

Field Value

PostgreSqlDataType

Float8

Represents the FLOAT8 type.

public static readonly PostgreSqlDataType Float8

Field Value

PostgreSqlDataType

Int2

Represents the INT2 type.

public static readonly PostgreSqlDataType Int2

Field Value

PostgreSqlDataType

Int4

Represents the INT4 type.

public static readonly PostgreSqlDataType Int4

Field Value

PostgreSqlDataType

Int8

Represents the INT8 type.

public static readonly PostgreSqlDataType Int8

Field Value

PostgreSqlDataType

Time

Represents the TIME type.

public static readonly PostgreSqlDataType Time

Field Value

PostgreSqlDataType

Timestamp

Represents the TIMESTAMP type.

public static readonly PostgreSqlDataType Timestamp

Field Value

PostgreSqlDataType

TimestampTz

Represents the TIMESTAMPTZ type.

public static readonly PostgreSqlDataType TimestampTz

Field Value

PostgreSqlDataType

Uuid

Represents the UUID type.

public static readonly PostgreSqlDataType Uuid

Field Value

PostgreSqlDataType

VarChar

Represents the VARCHAR type with default 10485760 maximum length.

public static readonly PostgreSqlDataType VarChar

Field Value

PostgreSqlDataType

Properties

DbType

DbType of this data type.

public DbType DbType { get; }

Property Value

DbType

Dialect

Specifies the SQL dialect of this data type.

public SqlDialect Dialect { get; }

Property Value

SqlDialect

Name

DB name of this data type.

public string Name { get; }

Property Value

string

ParameterDefinitions

Collection of parameter definitions for this data type.

public ReadOnlySpan<SqlDataTypeParameter> ParameterDefinitions { get; }

Property Value

ReadOnlySpan<SqlDataTypeParameter>

Parameters

Collection of applied parameters to this data type.

public ReadOnlySpan<int> Parameters { get; }

Property Value

ReadOnlySpan<int>

Value

Underlying value.

public NpgsqlDbType Value { get; }

Property Value

NpgsqlDbType

Methods

CompareTo(PostgreSqlDataType?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(PostgreSqlDataType? other)

Parameters

other PostgreSqlDataType

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

[Pure]
public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

CreateDecimal(int, int)

Creates a new DECIMAL type.

[Pure]
public static PostgreSqlDataType CreateDecimal(int precision, int scale)

Parameters

precision int

Desired precision.

scale int

Desired scale.

Returns

PostgreSqlDataType

PostgreSqlDataType instance that represents the desired DECIMAL type.

Exceptions

SqlDataTypeException

When precision is not in [0, 1000] range or when scale is not in [-1000, 1000] range.

CreateVarChar(int)

Creates a new VARCHAR type.

[Pure]
public static PostgreSqlDataType CreateVarChar(int maxLength)

Parameters

maxLength int

Desired maximum length.

Returns

PostgreSqlDataType

PostgreSqlDataType instance that represents the desired VARCHAR type.

Exceptions

SqlDataTypeException

When maxLength is less than 0.

Custom(string, NpgsqlDbType, DbType)

Creates a new custom type.

[Pure]
public static PostgreSqlDataType Custom(string name, NpgsqlDbType value, DbType dbType)

Parameters

name string

DB name of this data type.

value NpgsqlDbType

Underlying value.

dbType DbType

DbType of this data type.

Returns

PostgreSqlDataType

New PostgreSqlDataType instance.

Equals(PostgreSqlDataType?)

Indicates whether the current object is equal to another object of the same type.

[Pure]
public bool Equals(PostgreSqlDataType? other)

Parameters

other PostgreSqlDataType

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

[Pure]
public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

[Pure]
public override int GetHashCode()

Returns

int

A hash code for the current object.

ToString()

Returns a string representation of this PostgreSqlDataType instance.

[Pure]
public override string ToString()

Returns

string

String representation.

Operators

operator ==(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is equal to b.

[Pure]
public static bool operator ==(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when operands are equal, otherwise false.

operator >(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is greater than b.

[Pure]
public static bool operator >(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when a is greater than b, otherwise false.

operator >=(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is greater than or equal to b.

[Pure]
public static bool operator >=(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when a is greater than or equal to b, otherwise false.

implicit operator NpgsqlDbType(PostgreSqlDataType)

Converts this instance to the underlying value type. Returns Value of t.

[Pure]
public static implicit operator NpgsqlDbType(PostgreSqlDataType t)

Parameters

t PostgreSqlDataType

Data type to convert.

Returns

NpgsqlDbType

Value of t.

operator !=(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is not equal to b.

[Pure]
public static bool operator !=(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when operands are not equal, otherwise false.

operator <(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is less than b.

[Pure]
public static bool operator <(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when a is less than b, otherwise false.

operator <=(PostgreSqlDataType?, PostgreSqlDataType?)

Checks if a is less than or equal to b.

[Pure]
public static bool operator <=(PostgreSqlDataType? a, PostgreSqlDataType? b)

Parameters

a PostgreSqlDataType

First operand.

b PostgreSqlDataType

Second operand.

Returns

bool

true when a is less than or equal to b, otherwise false.