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
    NumericHandler
    SingleHandler
    UInt32Handler
    UuidHandler
    NpgsqlSimpleTypeHandlerWithPsv<TDefault, TPsv>
    Implements
    INpgsqlTypeHandler<TDefault>
    INpgsqlSimpleTypeHandler<TDefault>
    Inherited Members
    NpgsqlTypeHandler<TDefault>.WriteWithLength<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean)
    NpgsqlTypeHandler<TDefault>.CreateArrayHandler(PostgresArrayType)
    NpgsqlTypeHandler<TDefault>.CreateRangeHandler(PostgresRangeType)
    NpgsqlTypeHandler.CreateConversionButNoParamException(Type)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Npgsql.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

    | Improve this Doc

    NpgsqlSimpleTypeHandler(PostgresType)

    Constructs an NpgsqlSimpleTypeHandler<TDefault>.

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

    Methods

    | Improve this Doc

    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.

    | Improve this Doc

    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. This method is sealed for NpgsqlSimpleTypeHandler<TDefault>, override Read(NpgsqlReadBuffer, Int32, FieldDescription).

    Declaration
    public sealed override 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.

    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.Read(Npgsql.NpgsqlReadBuffer, System.Int32, System.Boolean, Npgsql.BackendMessages.FieldDescription)
    | Improve this Doc

    Read<TAny>(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. Type handlers typically don't need to override this - override Read(NpgsqlReadBuffer, Int32, FieldDescription) - but may do so in exceptional cases where reading of arbitrary types is required.

    Declaration
    public override TAny Read<TAny>(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
    TAny

    The fully-read value.

    Type Parameters
    Name Description
    TAny
    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.Read<TAny>(Npgsql.NpgsqlReadBuffer, System.Int32, Npgsql.BackendMessages.FieldDescription)
    | Improve this Doc

    Read<TAny>(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. This method is sealed for NpgsqlSimpleTypeHandler<TDefault>.

    Declaration
    protected sealed override async ValueTask<TAny> Read<TAny>(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<TAny>

    The fully-read value.

    Type Parameters
    Name Description
    TAny
    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.Read<TAny>(Npgsql.NpgsqlReadBuffer, System.Int32, System.Boolean, Npgsql.BackendMessages.FieldDescription)
    | Improve this Doc

    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.TypeHandling.NpgsqlTypeHandler<TDefault>.ValidateAndGetLength(TDefault, Npgsql.NpgsqlLengthCache, Npgsql.NpgsqlParameter)
    | Improve this Doc

    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.

    | Improve this Doc

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

    This method is sealed, override ValidateAndGetLength(TDefault, NpgsqlParameter).

    Declaration
    protected override int ValidateAndGetLength<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.TypeHandling.NpgsqlTypeHandler<TDefault>.ValidateAndGetLength<TAny>(TAny, Npgsql.NpgsqlLengthCache, Npgsql.NpgsqlParameter)
    | Improve this Doc

    ValidateObjectAndGetLength(Object, ref NpgsqlLengthCache, NpgsqlParameter)

    Called to validate and get the length of a value of a non-generic NpgsqlParameter. Type handlers generally don't need to override this.

    Declaration
    protected override int ValidateObjectAndGetLength(object value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    Object value
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Returns
    Type Description
    Int32
    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.ValidateObjectAndGetLength(System.Object, Npgsql.NpgsqlLengthCache, Npgsql.NpgsqlParameter)
    | Improve this Doc

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

    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)
    Parameters
    Type Name Description
    TDefault value
    NpgsqlWriteBuffer buf
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Boolean async
    Returns
    Type Description
    Task
    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.Write(TDefault, Npgsql.NpgsqlWriteBuffer, Npgsql.NpgsqlLengthCache, Npgsql.NpgsqlParameter, System.Boolean)
    | Improve this Doc

    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).

    | Improve this Doc

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

    Called to write the value of a non-generic NpgsqlParameter. Type handlers generally don't need to override this.

    Declaration
    protected override Task WriteObjectWithLength(object value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
    Parameters
    Type Name Description
    Object value
    NpgsqlWriteBuffer buf
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Boolean async
    Returns
    Type Description
    Task
    Overrides
    Npgsql.TypeHandling.NpgsqlTypeHandler<TDefault>.WriteObjectWithLength(System.Object, Npgsql.NpgsqlWriteBuffer, Npgsql.NpgsqlLengthCache, Npgsql.NpgsqlParameter, System.Boolean)

    Implements

    INpgsqlTypeHandler<T>
    INpgsqlSimpleTypeHandler<T>
    • Improve this Doc
    In This Article
    Back to top © Copyright 2021 The Npgsql Development Team