Table of Contents

Class MySqlDataType

Namespace
LfrlAnvil.MySql
Assembly
LfrlAnvil.MySql.dll

Represents a DB data type.

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

Remarks

MySqlDialect implementation.

Fields

BigInt

Represents the BIGINT type.

public static readonly MySqlDataType BigInt

Field Value

MySqlDataType

Binary

Represents the BINARY type with default 255 length.

public static readonly MySqlDataType Binary

Field Value

MySqlDataType

Blob

Represents the LONGBLOB type.

public static readonly MySqlDataType Blob

Field Value

MySqlDataType

Bool

Represents the BOOL type.

public static readonly MySqlDataType Bool

Field Value

MySqlDataType

Char

Represents the CHAR type with default 255 length.

public static readonly MySqlDataType Char

Field Value

MySqlDataType

Date

Represents the DATE type.

public static readonly MySqlDataType Date

Field Value

MySqlDataType

DateTime

Represents the DATETIME(6) type.

public static readonly MySqlDataType DateTime

Field Value

MySqlDataType

Decimal

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

public static readonly MySqlDataType Decimal

Field Value

MySqlDataType

Double

Represents the DOUBLE type.

public static readonly MySqlDataType Double

Field Value

MySqlDataType

Float

Represents the FLOAT type.

public static readonly MySqlDataType Float

Field Value

MySqlDataType

Int

Represents the INT type.

public static readonly MySqlDataType Int

Field Value

MySqlDataType

SmallInt

Represents the SMALLINT type.

public static readonly MySqlDataType SmallInt

Field Value

MySqlDataType

Text

Represents the LONGTEXT type.

public static readonly MySqlDataType Text

Field Value

MySqlDataType

Time

Represents the TIME(6) type.

public static readonly MySqlDataType Time

Field Value

MySqlDataType

TinyInt

Represents the TINYINT type.

public static readonly MySqlDataType TinyInt

Field Value

MySqlDataType

UnsignedBigInt

Represents the BIGINT UNSIGNED type.

public static readonly MySqlDataType UnsignedBigInt

Field Value

MySqlDataType

UnsignedInt

Represents the INT UNSIGNED type.

public static readonly MySqlDataType UnsignedInt

Field Value

MySqlDataType

UnsignedSmallInt

Represents the SMALLINT UNSIGNED type.

public static readonly MySqlDataType UnsignedSmallInt

Field Value

MySqlDataType

UnsignedTinyInt

Represents the TINYINT UNSIGNED type.

public static readonly MySqlDataType UnsignedTinyInt

Field Value

MySqlDataType

VarBinary

Represents the VARBINARY type with default 65535 maximum length.

public static readonly MySqlDataType VarBinary

Field Value

MySqlDataType

VarChar

Represents the VARCHAR type with default 65535 maximum length.

public static readonly MySqlDataType VarChar

Field Value

MySqlDataType

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 MySqlDbType Value { get; }

Property Value

MySqlDbType

Methods

CompareTo(MySqlDataType?)

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(MySqlDataType? other)

Parameters

other MySqlDataType

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.

CreateBinary(int)

Creates a new BINARY type.

[Pure]
public static MySqlDataType CreateBinary(int length)

Parameters

length int

Desired length.

Returns

MySqlDataType

MySqlDataType instance that represents the desired BINARY type.

Exceptions

SqlDataTypeException

When length is not in [0, 255] range.

CreateChar(int)

Creates a new CHAR type.

[Pure]
public static MySqlDataType CreateChar(int length)

Parameters

length int

Desired length.

Returns

MySqlDataType

MySqlDataType instance that represents the desired CHAR type.

Exceptions

SqlDataTypeException

When length is not in [0, 255] range.

CreateDecimal(int, int)

Creates a new DECIMAL type.

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

Parameters

precision int

Desired precision.

scale int

Desired scale.

Returns

MySqlDataType

MySqlDataType instance that represents the desired DECIMAL type.

Exceptions

SqlDataTypeException

When precision is not in [0, 65] range or when scale is not in [0, 30] range.

CreateVarBinary(int)

Creates a new VARBINARY type.

[Pure]
public static MySqlDataType CreateVarBinary(int maxLength)

Parameters

maxLength int

Desired maximum length.

Returns

MySqlDataType

MySqlDataType instance that represents the desired VARBINARY type.

Exceptions

SqlDataTypeException

When maxLength is not in [0, 65535] range.

CreateVarChar(int)

Creates a new VARCHAR type.

[Pure]
public static MySqlDataType CreateVarChar(int maxLength)

Parameters

maxLength int

Desired maximum length.

Returns

MySqlDataType

MySqlDataType instance that represents the desired VARCHAR type.

Exceptions

SqlDataTypeException

When maxLength is not in [0, 65535] range.

Custom(string, MySqlDbType, DbType)

Creates a new custom type.

[Pure]
public static MySqlDataType Custom(string name, MySqlDbType value, DbType dbType)

Parameters

name string

DB name of this data type.

value MySqlDbType

Underlying value.

dbType DbType

DbType of this data type.

Returns

MySqlDataType

New MySqlDataType instance.

Equals(MySqlDataType?)

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

[Pure]
public bool Equals(MySqlDataType? other)

Parameters

other MySqlDataType

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 MySqlDataType instance.

[Pure]
public override string ToString()

Returns

string

String representation.

Operators

operator ==(MySqlDataType?, MySqlDataType?)

Checks if a is equal to b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

true when operands are equal, otherwise false.

operator >(MySqlDataType?, MySqlDataType?)

Checks if a is greater than b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

true when a is greater than b, otherwise false.

operator >=(MySqlDataType?, MySqlDataType?)

Checks if a is greater than or equal to b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

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

implicit operator MySqlDbType(MySqlDataType)

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

[Pure]
public static implicit operator MySqlDbType(MySqlDataType t)

Parameters

t MySqlDataType

Data type to convert.

Returns

MySqlDbType

Value of t.

operator !=(MySqlDataType?, MySqlDataType?)

Checks if a is not equal to b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

true when operands are not equal, otherwise false.

operator <(MySqlDataType?, MySqlDataType?)

Checks if a is less than b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

true when a is less than b, otherwise false.

operator <=(MySqlDataType?, MySqlDataType?)

Checks if a is less than or equal to b.

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

Parameters

a MySqlDataType

First operand.

b MySqlDataType

Second operand.

Returns

bool

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