Table of Contents

Interface INpgsqlSimpleTypeHandler<T>

Namespace
Npgsql.TypeHandling
Assembly
Npgsql.dll

Type handlers that wish to support reading other types in additional to the main one can implement this interface for all those types.

public interface INpgsqlSimpleTypeHandler<T>

Type Parameters

T

Methods

Read(NpgsqlReadBuffer, int, FieldDescription)

Reads a value of type T with the given length from the provided buffer, with the assumption that it is entirely present in the provided memory buffer and no I/O will be required.

T Read(NpgsqlReadBuffer buf, int len, FieldDescription fieldDescription = null)

Parameters

buf NpgsqlReadBuffer

The buffer from which to read.

len int

The byte length of the value. The buffer might not contain the full length, requiring I/O to be performed.

fieldDescription FieldDescription

Additional PostgreSQL information about the type, such as the length in varchar(30).

Returns

T

The fully-read value.

ValidateAndGetLength(T, 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.

int ValidateAndGetLength(T value, NpgsqlParameter parameter)

Parameters

value T

The value to be written to PostgreSQL

parameter NpgsqlParameter

The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).

Returns

int

The number of bytes required to write the value.

Write(T, NpgsqlWriteBuffer, NpgsqlParameter)

Writes a value to the provided buffer, with the assumption that there is enough space in the buffer (no I/O will occur). The Npgsql core will have taken care of that.

void Write(T value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)

Parameters

value T

The value to write.

buf NpgsqlWriteBuffer

The buffer to which to write.

parameter NpgsqlParameter

The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).