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
Bytea
Represents the BYTEA type.
public static readonly PostgreSqlDataType Bytea
Field Value
Date
Represents the DATE type.
public static readonly PostgreSqlDataType Date
Field Value
Decimal
Represents the DECIMAL type with default 29 scale and 10 precision.
public static readonly PostgreSqlDataType Decimal
Field Value
Float4
Represents the FLOAT4 type.
public static readonly PostgreSqlDataType Float4
Field Value
Float8
Represents the FLOAT8 type.
public static readonly PostgreSqlDataType Float8
Field Value
Int2
Represents the INT2 type.
public static readonly PostgreSqlDataType Int2
Field Value
Int4
Represents the INT4 type.
public static readonly PostgreSqlDataType Int4
Field Value
Int8
Represents the INT8 type.
public static readonly PostgreSqlDataType Int8
Field Value
Time
Represents the TIME type.
public static readonly PostgreSqlDataType Time
Field Value
Timestamp
Represents the TIMESTAMP type.
public static readonly PostgreSqlDataType Timestamp
Field Value
TimestampTz
Represents the TIMESTAMPTZ type.
public static readonly PostgreSqlDataType TimestampTz
Field Value
Uuid
Represents the UUID type.
public static readonly PostgreSqlDataType Uuid
Field Value
VarChar
Represents the VARCHAR type with default 10485760 maximum length.
public static readonly PostgreSqlDataType VarChar
Field Value
Properties
DbType
DbType of this data type.
public DbType DbType { get; }
Property Value
Dialect
Specifies the SQL dialect of this data type.
public SqlDialect Dialect { get; }
Property Value
Name
DB name of this data type.
public string Name { get; }
Property Value
ParameterDefinitions
Collection of parameter definitions for this data type.
public ReadOnlySpan<SqlDataTypeParameter> ParameterDefinitions { get; }
Property Value
Parameters
Collection of applied parameters to this data type.
public ReadOnlySpan<int> Parameters { get; }
Property Value
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
PostgreSqlDataTypeAn 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
objectAn 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
Returns
- PostgreSqlDataType
PostgreSqlDataType instance that represents the desired DECIMAL type.
Exceptions
- SqlDataTypeException
When
precision
is not in [0, 1000] range or whenscale
is not in [-1000, 1000] range.
CreateVarChar(int)
Creates a new VARCHAR type.
[Pure]
public static PostgreSqlDataType CreateVarChar(int maxLength)
Parameters
maxLength
intDesired 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
stringDB name of this data type.
value
NpgsqlDbTypeUnderlying value.
dbType
DbTypeDbType 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
PostgreSqlDataTypeAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond 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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond operand.
Returns
- bool
true when
a
is greater thanb
, 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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond operand.
Returns
- bool
true when
a
is greater than or equal tob
, 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
PostgreSqlDataTypeData 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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond 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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond operand.
Returns
- bool
true when
a
is less thanb
, 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
PostgreSqlDataTypeFirst operand.
b
PostgreSqlDataTypeSecond operand.
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.