Class NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
- Namespace
- Npgsql.TypeHandling
- Assembly
- Npgsql.dll
A simple type handler that supports a provider-specific value in addition to its default value.
This is necessary mainly in cases where the CLR type cannot represent the full range of the
PostgreSQL type, and a custom CLR type is needed (e.g. DateTime and
NpgsqlDateTime). The provider-specific type TPsv
will be returned
from calls to GetProviderSpecificValue(int).
public abstract class NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv> : NpgsqlSimpleTypeHandler<TDefault>, INpgsqlTypeHandler<TDefault>, INpgsqlSimpleTypeHandler<TDefault>, INpgsqlSimpleTypeHandler<TPsv>
Type Parameters
TDefault
The default CLR type that this handler will read and write. For example, calling GetValue(int) on a column with this handler will return a value with type
TDefault
. Type handlers can support additional types by implementing INpgsqlTypeHandler<T>.TPsv
The provider-specific CLR type that this handler will read and write.
- Inheritance
-
NpgsqlTypeHandler<TDefault>NpgsqlSimpleTypeHandler<TDefault>NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
- Implements
-
INpgsqlTypeHandler<TDefault>INpgsqlSimpleTypeHandler<TDefault>INpgsqlSimpleTypeHandler<TPsv>
- Inherited Members
Constructors
NpgsqlSimpleTypeHandlerWithPsv()
protected NpgsqlSimpleTypeHandlerWithPsv()
Methods
CreateArrayHandler(PostgresType)
public override ArrayHandler CreateArrayHandler(PostgresType arrayBackendType)
Parameters
arrayBackendType
PostgresType
Returns
ReadPsv(NpgsqlReadBuffer, int, FieldDescription)
Reads a value of type TPsv
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.
protected abstract TPsv ReadPsv(NpgsqlReadBuffer buf, int len, FieldDescription fieldDescription = null)
Parameters
buf
NpgsqlReadBufferThe buffer from which to read.
len
intThe byte length of the value. The buffer might not contain the full length, requiring I/O to be performed.
fieldDescription
FieldDescriptionAdditional PostgreSQL information about the type, such as the length in varchar(30).
Returns
- TPsv
The fully-read value.
ValidateAndGetLength(TPsv, 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.
public abstract int ValidateAndGetLength(TPsv value, NpgsqlParameter parameter)
Parameters
value
TPsvThe value to be written to PostgreSQL
parameter
NpgsqlParameterThe 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(TPsv, 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.
public abstract void Write(TPsv value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
Parameters
value
TPsvThe value to write.
buf
NpgsqlWriteBufferThe buffer to which to write.
parameter
NpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).