Class NpgsqlTypeHandler<TDefault>
Base class for all type handlers, which read and write CLR types into their PostgreSQL
binary representation. Unless your type is arbitrary-length, consider inheriting from
NpgsqlSimpleTypeHandler<TDefault> instead.
Inheritance
NpgsqlTypeHandler<TDefault>
Assembly: Npgsql.dll
Syntax
public abstract class NpgsqlTypeHandler<TDefault> : NpgsqlTypeHandler, INpgsqlTypeHandler<TDefault>
Type Parameters
Name |
Description |
TDefault |
The default CLR type that this handler will read and write. For example, calling GetValue(Int32)
on a column with this handler will return a value with type TDefault .
Type handlers can support additional types by implementing INpgsqlTypeHandler<T>.
|
Constructors
NpgsqlTypeHandler(PostgresType)
Declaration
protected NpgsqlTypeHandler(PostgresType postgresType)
Parameters
Methods
CreateArrayHandler(PostgresArrayType, ArrayNullabilityMode)
Creates a type handler for arrays of this handler's type.
Declaration
public override NpgsqlTypeHandler CreateArrayHandler(PostgresArrayType pgArrayType, ArrayNullabilityMode arrayNullabilityMode)
Parameters
Returns
Overrides
CreateMultirangeHandler(PostgresMultirangeType)
Creates a type handler for multiranges of this handler's type.
Declaration
public override NpgsqlTypeHandler CreateMultirangeHandler(PostgresMultirangeType pgMultirangeType)
Parameters
Returns
Overrides
CreateRangeHandler(PostgresType)
Creates a type handler for ranges of this handler's type.
Declaration
public override NpgsqlTypeHandler CreateRangeHandler(PostgresType pgRangeType)
Parameters
Returns
Overrides
GetFieldType(FieldDescription)
Declaration
public override Type GetFieldType(FieldDescription fieldDescription = null)
Parameters
Returns
Overrides
GetProviderSpecificFieldType(FieldDescription)
Declaration
public override Type GetProviderSpecificFieldType(FieldDescription fieldDescription = null)
Parameters
Returns
Overrides
Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Reads a value of type TDefault
with the given length from the provided buffer,
using either sync or async I/O.
Declaration
public abstract ValueTask<TDefault> Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
Parameters
Type |
Name |
Description |
NpgsqlReadBuffer |
buf |
The buffer from which to read.
|
Int32 |
len |
The byte length of the value. The buffer might not contain the full length, requiring I/O to be performed.
|
Boolean |
async |
If I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously.
|
FieldDescription |
fieldDescription |
Additional PostgreSQL information about the type, such as the length in varchar(30).
|
Returns
Type |
Description |
ValueTask<TDefault> |
The fully-read value.
|
ReadAsObject(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
public override async ValueTask<object> ReadAsObject(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
Parameters
Returns
Overrides
ValidateAndGetLength(TDefault, ref NpgsqlLengthCache, NpgsqlParameter)
Declaration
public abstract int ValidateAndGetLength(TDefault value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Returns
Write(TDefault, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Declaration
public abstract Task Write(TDefault value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Returns
Implements