Search Results for

    Show / Hide Table of Contents

    Class NpgsqlSimpleTypeHandler<TDefault>

    Base class for all simple type handlers, which read and write short, non-arbitrary lengthed values to PostgreSQL. Provides a simpler API to implement when compared to NpgsqlTypeHandler - Npgsql takes care of all I/O before calling into this type, so no I/O needs to be performed by it.

    Inheritance
    Object
    NpgsqlTypeHandler
    NpgsqlTypeHandler<TDefault>
    NpgsqlSimpleTypeHandler<TDefault>
    BoolHandler
    TimeHandler
    TimeTzHandler
    BoxHandler
    CircleHandler
    LineHandler
    LineSegmentHandler
    PointHandler
    InternalCharHandler
    CidrHandler
    MacaddrHandler
    DoubleHandler
    Int16Handler
    Int32Handler
    Int64Handler
    MoneyHandler
    SingleHandler
    UInt32Handler
    UInt64Handler
    UuidHandler
    NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
    Implements
    INpgsqlTypeHandler<TDefault>
    INpgsqlSimpleTypeHandler<TDefault>
    Inherited Members
    NpgsqlTypeHandler<TDefault>.ReadAsObject(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
    NpgsqlTypeHandler<TDefault>.GetFieldType(FieldDescription)
    NpgsqlTypeHandler<TDefault>.GetProviderSpecificFieldType(FieldDescription)
    NpgsqlTypeHandler<TDefault>.CreateArrayHandler(PostgresArrayType, ArrayNullabilityMode)
    NpgsqlTypeHandler<TDefault>.CreateRangeHandler(PostgresType)
    NpgsqlTypeHandler<TDefault>.CreateMultirangeHandler(PostgresMultirangeType)
    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 NpgsqlSimpleTypeHandler<TDefault> : NpgsqlTypeHandler<TDefault>, INpgsqlTypeHandler<TDefault>, INpgsqlSimpleTypeHandler<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

    NpgsqlSimpleTypeHandler(PostgresType)

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

    Methods

    Read(NpgsqlReadBuffer, Int32, FieldDescription)

    Reads a value of type TDefault 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
    public abstract TDefault Read(NpgsqlReadBuffer buf, int len, 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.

    FieldDescription fieldDescription

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

    Returns
    Type Description
    TDefault

    The fully-read value.

    Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

    Declaration
    public sealed override ValueTask<TDefault> Read(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<TDefault>
    Overrides
    Npgsql.Internal.TypeHandling.NpgsqlTypeHandler<TDefault>.Read(Npgsql.Internal.NpgsqlReadBuffer, System.Int32, System.Boolean, Npgsql.BackendMessages.FieldDescription)

    ValidateAndGetLength(TDefault, ref NpgsqlLengthCache, NpgsqlParameter)

    Simple type handlers override ValidateAndGetLength(TDefault, NpgsqlParameter) instead of this.

    Declaration
    public sealed override int ValidateAndGetLength(TDefault value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    TDefault value
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Returns
    Type Description
    Int32
    Overrides
    Npgsql.Internal.TypeHandling.NpgsqlTypeHandler<TDefault>.ValidateAndGetLength(TDefault, Npgsql.Internal.TypeHandling.NpgsqlLengthCache, Npgsql.NpgsqlParameter)

    ValidateAndGetLength(TDefault, 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(TDefault value, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    TDefault 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
    Int32

    The number of bytes required to write the value.

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

    Simple type handlers override Write(TDefault, NpgsqlWriteBuffer, NpgsqlParameter) instead of this.

    Declaration
    public sealed override 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
    Overrides
    Npgsql.Internal.TypeHandling.NpgsqlTypeHandler<TDefault>.Write(TDefault, Npgsql.Internal.NpgsqlWriteBuffer, Npgsql.Internal.TypeHandling.NpgsqlLengthCache, Npgsql.NpgsqlParameter, System.Boolean, System.Threading.CancellationToken)

    Write(TDefault, 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(TDefault value, NpgsqlWriteBuffer buf, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    TDefault 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).

    Implements

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