Class NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
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. System.DateTime and
NpgsqlDateTime). The provider-specific type TPsv
will be returned
from calls to System.Data.Common.DbDataReader.GetProviderSpecificValue(System.Int32).
Inheritance
Implements
Inherited Members
Namespace: Npgsql.TypeHandling
Assembly: Npgsql.dll
Syntax
public abstract class NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv> : NpgsqlSimpleTypeHandler<TDefault>, INpgsqlTypeHandler<TDefault>, INpgsqlSimpleTypeHandler<TDefault>, INpgsqlSimpleTypeHandler<TPsv>
Type Parameters
Name | Description |
---|---|
TDefault | The default CLR type that this handler will read and write. For example, calling System.Data.Common.DbDataReader.GetValue(System.Int32)
on a column with this handler will return a value with type |
TPsv | The provider-specific CLR type that this handler will read and write. |
Constructors
NpgsqlSimpleTypeHandlerWithPsv(PostgresType)
Constructs an NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
Declaration
protected NpgsqlSimpleTypeHandlerWithPsv(PostgresType postgresType)
Parameters
Type | Name | Description |
---|---|---|
PostgresType | postgresType |
Methods
CreateArrayHandler(PostgresArrayType)
Declaration
public override ArrayHandler CreateArrayHandler(PostgresArrayType arrayBackendType)
Parameters
Type | Name | Description |
---|---|---|
PostgresArrayType | arrayBackendType |
Returns
Type | Description |
---|---|
ArrayHandler |
Overrides
ReadPsv(NpgsqlReadBuffer, Int32, 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.
Declaration
protected abstract TPsv ReadPsv(NpgsqlReadBuffer buf, int len, FieldDescription fieldDescription = null)
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. |
FieldDescription | fieldDescription | Additional PostgreSQL information about the type, such as the length in varchar(30). |
Returns
Type | Description |
---|---|
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.
Declaration
public abstract int ValidateAndGetLength(TPsv value, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
TPsv | value | The value to be written to PostgreSQL |
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(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.
Declaration
public abstract void Write(TPsv value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
TPsv | value | The value to write. |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlParameter | parameter | The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size). |
Explicit Interface Implementations
INpgsqlSimpleTypeHandler<TPsv>.Read(NpgsqlReadBuffer, Int32, FieldDescription)
Declaration
TPsv INpgsqlSimpleTypeHandler<TPsv>.Read(NpgsqlReadBuffer buf, int len, FieldDescription fieldDescription)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlReadBuffer | buf | |
System.Int32 | len | |
FieldDescription | fieldDescription |
Returns
Type | Description |
---|---|
TPsv |