Show / Hide Table of Contents

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
System.Object
NpgsqlTypeHandler
NpgsqlTypeHandler<TDefault>
NpgsqlSimpleTypeHandler<TDefault>
NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
Implements
INpgsqlTypeHandler<TDefault>
INpgsqlSimpleTypeHandler<TDefault>
INpgsqlSimpleTypeHandler<TPsv>
Inherited Members
NpgsqlSimpleTypeHandler<TDefault>.Read(NpgsqlReadBuffer, Int32, FieldDescription)
NpgsqlSimpleTypeHandler<TDefault>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
NpgsqlSimpleTypeHandler<TDefault>.Read<TAny>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
NpgsqlSimpleTypeHandler<TDefault>.ValidateAndGetLength(TDefault, NpgsqlParameter)
NpgsqlSimpleTypeHandler<TDefault>.Write(TDefault, NpgsqlWriteBuffer, NpgsqlParameter)
NpgsqlSimpleTypeHandler<TDefault>.ValidateAndGetLength<TAny>(TAny, NpgsqlLengthCache, NpgsqlParameter)
NpgsqlSimpleTypeHandler<TDefault>.Write(TDefault, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean)
NpgsqlSimpleTypeHandler<TDefault>.ValidateAndGetLength(TDefault, NpgsqlLengthCache, NpgsqlParameter)
NpgsqlSimpleTypeHandler<TDefault>.ValidateObjectAndGetLength(Object, NpgsqlLengthCache, NpgsqlParameter)
NpgsqlSimpleTypeHandler<TDefault>.WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean)
NpgsqlTypeHandler<TDefault>.WriteWithLength<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean)
NpgsqlTypeHandler<TDefault>.CreateRangeHandler(PostgresType)
NpgsqlTypeHandler.CreateConversionButNoParamException(Type)
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
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 TDefault. Type handlers can support additional types by implementing INpgsqlTypeHandler<T>.

TPsv

The provider-specific CLR type that this handler will read and write.

Methods

CreateArrayHandler(PostgresType)

Declaration
public override ArrayHandler CreateArrayHandler(PostgresType arrayBackendType)
Parameters
Type Name Description
PostgresType arrayBackendType
Returns
Type Description
ArrayHandler
Overrides
Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.CreateArrayHandler(Npgsql.PostgresTypes.PostgresType)

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

Implements

INpgsqlTypeHandler<T>
INpgsqlSimpleTypeHandler<T>
INpgsqlSimpleTypeHandler<T>
Back to top Generated by DocFX