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
bufNpgsqlReadBufferThe buffer from which to read.
lenintThe byte length of the value. The buffer might not contain the full length, requiring I/O to be performed.
fieldDescriptionFieldDescriptionAdditional 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
valueTThe value to be written to PostgreSQL
parameterNpgsqlParameterThe 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
valueTThe value to write.
bufNpgsqlWriteBufferThe buffer to which to write.
parameterNpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).