Search Results for

    Show / Hide Table of Contents

    Class ArrayHandler<TElement>

    Base class for all type handlers which handle PostgreSQL arrays.

    Inheritance
    Object
    NpgsqlTypeHandler
    ArrayHandler
    ArrayHandler<TElement>
    BitStringArrayHandler
    Inherited Members
    ArrayHandler.GetFieldType(FieldDescription)
    ArrayHandler.GetProviderSpecificFieldType(FieldDescription)
    ArrayHandler.CreateArrayHandler(PostgresArrayType, ArrayNullabilityMode)
    ArrayHandler.CreateRangeHandler(PostgresType)
    ArrayHandler.CreateMultirangeHandler(PostgresMultirangeType)
    ArrayHandler.ReadCustom<TRequestedArray>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
    ArrayHandler.ReadArray<TRequestedElement>(NpgsqlReadBuffer, Boolean, Int32, Boolean)
    ArrayHandler.ReadList<TRequestedElement>(NpgsqlReadBuffer, Boolean)
    NpgsqlTypeHandler.PostgresType
    NpgsqlTypeHandler.Read<TAny>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
    NpgsqlTypeHandler.Read<TAny>(NpgsqlReadBuffer, Int32, FieldDescription)
    NpgsqlTypeHandler.ValidateAndGetLength<TAny>(TAny, NpgsqlLengthCache, NpgsqlParameter)
    NpgsqlTypeHandler.WriteWithLength<TAny>(TAny, 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.TypeHandlers
    Assembly: Npgsql.dll
    Syntax
    public class ArrayHandler<TElement> : ArrayHandler
    Type Parameters
    Name Description
    TElement
    Remarks

    https://www.postgresql.org/docs/current/static/arrays.html.

    The type handler API allows customizing Npgsql's behavior in powerful ways. However, although it is public, it should be considered somewhat unstable, and may change in breaking ways, including in non-major releases. Use it at your own risk.

    Constructors

    ArrayHandler(PostgresType, NpgsqlTypeHandler, ArrayNullabilityMode, Int32)

    Declaration
    public ArrayHandler(PostgresType arrayPostgresType, NpgsqlTypeHandler elementHandler, ArrayNullabilityMode arrayNullabilityMode, int lowerBound = 1)
    Parameters
    Type Name Description
    PostgresType arrayPostgresType
    NpgsqlTypeHandler elementHandler
    ArrayNullabilityMode arrayNullabilityMode
    Int32 lowerBound

    Methods

    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)

    ValidateAndGetLengthCustom<TAny>(TAny, ref NpgsqlLengthCache, NpgsqlParameter)

    Declaration
    protected override int ValidateAndGetLengthCustom<TAny>(TAny value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    TAny value
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Returns
    Type Description
    Int32
    Type Parameters
    Name Description
    TAny
    Overrides
    Npgsql.Internal.TypeHandling.NpgsqlTypeHandler.ValidateAndGetLengthCustom<TAny>(TAny, Npgsql.Internal.TypeHandling.NpgsqlLengthCache, Npgsql.NpgsqlParameter)

    ValidateObjectAndGetLength(Object, ref NpgsqlLengthCache, 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 override int ValidateObjectAndGetLength(object value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    Object value

    The value to be written to PostgreSQL

    NpgsqlLengthCache lengthCache

    If the byte length calculation is costly (e.g. for UTF-8 strings), its result can be stored in the length cache to be reused in the writing process, preventing recalculation.

    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
    Int32

    The number of bytes required to write the value.

    Overrides
    NpgsqlTypeHandler.ValidateObjectAndGetLength(Object, ref NpgsqlLengthCache, NpgsqlParameter)

    WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    Writes a value to the provided buffer, using either sync or async I/O.

    Declaration
    public override Task WriteObjectWithLength(object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    Object value

    The value to write.

    NpgsqlWriteBuffer buf

    The buffer to which to write.

    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter

    The NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).

    Boolean async

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

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task
    Overrides
    NpgsqlTypeHandler.WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    WriteWithLengthCustom<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    Declaration
    protected override Task WriteWithLengthCustom<TAny>(TAny value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    TAny value
    NpgsqlWriteBuffer buf
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Boolean async
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    TAny
    Overrides
    Npgsql.Internal.TypeHandling.NpgsqlTypeHandler.WriteWithLengthCustom<TAny>(TAny, Npgsql.Internal.NpgsqlWriteBuffer, Npgsql.Internal.TypeHandling.NpgsqlLengthCache, Npgsql.NpgsqlParameter, System.Boolean, System.Threading.CancellationToken)
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team