Interface INpgsqlTypeHandler<T>
Type handlers that wish to support reading other types in additional to the main one can implement this interface for all those types.
Namespace: Npgsql.TypeHandling
Assembly: Npgsql.dll
Syntax
public interface INpgsqlTypeHandler<T>
Type Parameters
Name | Description |
---|---|
T |
Methods
Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Reads a value of type T
with the given length from the provided buffer,
using either sync or async I/O.
Declaration
ValueTask<T> Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | The buffer from which to read. |
System.Int32 | len | The byte length of the value. The buffer might not contain the full length, requiring I/O to be performed. |
System.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 |
---|---|
System.Threading.Tasks.ValueTask<T> | The fully-read value. |
ValidateAndGetLength(T, ref NpgsqlLengthCache, NpgsqlParameter)
Responsible for validating that a value represents a value of the correct and which can be written for PostgreSQL - if the value cannot be written for any reason, an exception shold be thrown. Also returns the byte length needed to write the value.
Declaration
int ValidateAndGetLength(T value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written to PostgreSQL |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes required to write the value. |
Write(T, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean)
Writes a value to the provided buffer.
Declaration
Task Write(T value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to write. |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | A cache where the length calculated during the validation phase can be stored for use at the writing phase. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
System.Boolean | async | If I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |