Search Results for

    Show / Hide Table of Contents

    Interface INpgsqlTypeHandler<T>

    Type handlers that wish to support reading other types in additional to the main one can implement this interface for all those types.

    Namespace: Npgsql.Internal.TypeHandling
    Assembly: Npgsql.dll
    Syntax
    public interface INpgsqlTypeHandler<T>
    Type Parameters
    Name Description
    T

    Methods

    Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

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

    Declaration
    ValueTask<T> 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<T>

    The fully-read value.

    ValidateAndGetLength(T, 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 should be thrown. Also returns the byte length needed to write the value.

    Declaration
    int ValidateAndGetLength(T value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    T value

    The value to be written to PostgreSQL

    NpgsqlLengthCache lengthCache

    A cache where the length calculated during the validation phase can be stored for use at the writing phase.

    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.

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

    Writes a value to the provided buffer.

    Declaration
    Task Write(T value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    T value

    The value to write.

    NpgsqlWriteBuffer buf

    The buffer to which to write.

    NpgsqlLengthCache lengthCache

    A cache where the length calculated during the validation phase can be stored for use at the writing phase.

    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 will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.

    CancellationToken cancellationToken

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

    Returns
    Type Description
    Task
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team