Search Results for

    Show / Hide Table of Contents

    Class NpgsqlTypeHandler<TDefault>

    Base class for all type handlers, which read and write CLR types into their PostgreSQL binary representation. Unless your type is arbitrary-length, consider inheriting from NpgsqlSimpleTypeHandler<TDefault> instead.

    Inheritance
    Object
    NpgsqlTypeHandler
    NpgsqlTypeHandler<TDefault>
    BitStringHandler
    ByteaHandler
    TsQueryHandler
    TsVectorHandler
    PathHandler
    PolygonHandler
    HstoreHandler
    JsonHandler
    JsonPathHandler
    MultirangeHandler<TSubtype>
    NumericHandler
    TextHandler
    NpgsqlSimpleTypeHandler<TDefault>
    Implements
    INpgsqlTypeHandler<TDefault>
    Inherited Members
    NpgsqlTypeHandler.PostgresType
    NpgsqlTypeHandler.Read<TAny>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
    NpgsqlTypeHandler.Read<TAny>(NpgsqlReadBuffer, Int32, FieldDescription)
    NpgsqlTypeHandler.ReadCustom<TAny>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
    NpgsqlTypeHandler.ValidateAndGetLength<TAny>(TAny, NpgsqlLengthCache, NpgsqlParameter)
    NpgsqlTypeHandler.ValidateAndGetLengthCustom<TAny>(TAny, NpgsqlLengthCache, NpgsqlParameter)
    NpgsqlTypeHandler.WriteWithLength<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
    NpgsqlTypeHandler.WriteWithLengthCustom<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
    NpgsqlTypeHandler.ValidateObjectAndGetLength(Object, NpgsqlLengthCache, NpgsqlParameter)
    NpgsqlTypeHandler.WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
    NpgsqlTypeHandler.CreateConversionButNoParamException(Type)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Npgsql.Internal.TypeHandling
    Assembly: Npgsql.dll
    Syntax
    public abstract class NpgsqlTypeHandler<TDefault> : NpgsqlTypeHandler, INpgsqlTypeHandler<TDefault>
    Type Parameters
    Name Description
    TDefault

    The default CLR type that this handler will read and write. For example, calling GetValue(Int32) on a column with this handler will return a value with type TDefault. Type handlers can support additional types by implementing INpgsqlTypeHandler<T>.

    Constructors

    NpgsqlTypeHandler(PostgresType)

    Declaration
    protected NpgsqlTypeHandler(PostgresType postgresType)
    Parameters
    Type Name Description
    PostgresType postgresType

    Methods

    CreateArrayHandler(PostgresArrayType, ArrayNullabilityMode)

    Creates a type handler for arrays of this handler's type.

    Declaration
    public override NpgsqlTypeHandler CreateArrayHandler(PostgresArrayType pgArrayType, ArrayNullabilityMode arrayNullabilityMode)
    Parameters
    Type Name Description
    PostgresArrayType pgArrayType
    ArrayNullabilityMode arrayNullabilityMode
    Returns
    Type Description
    NpgsqlTypeHandler
    Overrides
    NpgsqlTypeHandler.CreateArrayHandler(PostgresArrayType, ArrayNullabilityMode)

    CreateMultirangeHandler(PostgresMultirangeType)

    Creates a type handler for multiranges of this handler's type.

    Declaration
    public override NpgsqlTypeHandler CreateMultirangeHandler(PostgresMultirangeType pgMultirangeType)
    Parameters
    Type Name Description
    PostgresMultirangeType pgMultirangeType
    Returns
    Type Description
    NpgsqlTypeHandler
    Overrides
    NpgsqlTypeHandler.CreateMultirangeHandler(PostgresMultirangeType)

    CreateRangeHandler(PostgresType)

    Creates a type handler for ranges of this handler's type.

    Declaration
    public override NpgsqlTypeHandler CreateRangeHandler(PostgresType pgRangeType)
    Parameters
    Type Name Description
    PostgresType pgRangeType
    Returns
    Type Description
    NpgsqlTypeHandler
    Overrides
    NpgsqlTypeHandler.CreateRangeHandler(PostgresType)

    GetFieldType(FieldDescription)

    Declaration
    public override Type GetFieldType(FieldDescription fieldDescription = null)
    Parameters
    Type Name Description
    FieldDescription fieldDescription
    Returns
    Type Description
    Type
    Overrides
    NpgsqlTypeHandler.GetFieldType(FieldDescription)

    GetProviderSpecificFieldType(FieldDescription)

    Declaration
    public override Type GetProviderSpecificFieldType(FieldDescription fieldDescription = null)
    Parameters
    Type Name Description
    FieldDescription fieldDescription
    Returns
    Type Description
    Type
    Overrides
    NpgsqlTypeHandler.GetProviderSpecificFieldType(FieldDescription)

    Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

    Reads a value of type TDefault with the given length from the provided buffer, using either sync or async I/O.

    Declaration
    public abstract ValueTask<TDefault> Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
    Parameters
    Type Name Description
    NpgsqlReadBuffer buf

    The buffer from which to read.

    Int32 len

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

    Boolean async

    If I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously.

    FieldDescription fieldDescription

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

    Returns
    Type Description
    ValueTask<TDefault>

    The fully-read value.

    ReadAsObject(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

    Declaration
    public override async ValueTask<object> ReadAsObject(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
    Parameters
    Type Name Description
    NpgsqlReadBuffer buf
    Int32 len
    Boolean async
    FieldDescription fieldDescription
    Returns
    Type Description
    ValueTask<Object>
    Overrides
    NpgsqlTypeHandler.ReadAsObject(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

    ValidateAndGetLength(TDefault, ref NpgsqlLengthCache, NpgsqlParameter)

    Called to validate and get the length of a value of a generic NpgsqlParameter<T>.

    Declaration
    public abstract int ValidateAndGetLength(TDefault value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    TDefault value
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Returns
    Type Description
    Int32

    Write(TDefault, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    Called to write the value of a generic NpgsqlParameter<T>.

    Declaration
    public abstract Task Write(TDefault value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    TDefault value
    NpgsqlWriteBuffer buf
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Boolean async
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Implements

    INpgsqlTypeHandler<T>
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team