Search Results for

    Show / Hide Table of Contents

    Class RangeHandler<TSubtype>

    A type handler for PostgreSQL range types.

    Inheritance
    Object
    NpgsqlTypeHandler
    RangeHandler<TSubtype>
    RangeHandler<TSubtype1, TSubtype2>
    DateRangeHandler
    TimestampTzRangeHandler
    Implements
    INpgsqlTypeHandler<NpgsqlRange<TSubtype>>
    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.TypeHandlers
    Assembly: Npgsql.dll
    Syntax
    public class RangeHandler<TSubtype> : NpgsqlTypeHandler, INpgsqlTypeHandler<NpgsqlRange<TSubtype>>
    Type Parameters
    Name Description
    TSubtype

    The range subtype.

    Remarks

    See https://www.postgresql.org/docs/current/static/rangetypes.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

    RangeHandler(PostgresType, NpgsqlTypeHandler)

    Declaration
    public RangeHandler(PostgresType rangePostgresType, NpgsqlTypeHandler subtypeHandler)
    Parameters
    Type Name Description
    PostgresType rangePostgresType
    NpgsqlTypeHandler subtypeHandler

    Properties

    SubtypeHandler

    The type handler for the subtype that this range type holds

    Declaration
    protected NpgsqlTypeHandler SubtypeHandler { get; }
    Property Value
    Type Description
    NpgsqlTypeHandler

    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 T with the given length from the provided buffer, using either sync or async I/O.

    Declaration
    public ValueTask<NpgsqlRange<TSubtype>> 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<NpgsqlRange<TSubtype>>

    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)

    ReadRange<TAnySubtype>(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)

    Declaration
    protected async ValueTask<NpgsqlRange<TAnySubtype>> ReadRange<TAnySubtype>(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription)
    Parameters
    Type Name Description
    NpgsqlReadBuffer buf
    Int32 len
    Boolean async
    FieldDescription fieldDescription
    Returns
    Type Description
    ValueTask<NpgsqlRange<TAnySubtype>>
    Type Parameters
    Name Description
    TAnySubtype

    ValidateAndGetLength(NpgsqlRange<TSubtype>, 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
    public int ValidateAndGetLength(NpgsqlRange<TSubtype> value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    NpgsqlRange<TSubtype> value
    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.

    ValidateAndGetLengthRange<TAnySubtype>(NpgsqlRange<TAnySubtype>, ref NpgsqlLengthCache, NpgsqlParameter)

    Declaration
    protected int ValidateAndGetLengthRange<TAnySubtype>(NpgsqlRange<TAnySubtype> value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
    Parameters
    Type Name Description
    NpgsqlRange<TAnySubtype> value
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Returns
    Type Description
    Int32
    Type Parameters
    Name Description
    TAnySubtype

    Write(NpgsqlRange<TSubtype>, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    Writes a value to the provided buffer.

    Declaration
    public Task Write(NpgsqlRange<TSubtype> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    NpgsqlRange<TSubtype> value
    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

    WriteRange<TAnySubtype>(NpgsqlRange<TAnySubtype>, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)

    Declaration
    protected async Task WriteRange<TAnySubtype>(NpgsqlRange<TAnySubtype> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    NpgsqlRange<TAnySubtype> value
    NpgsqlWriteBuffer buf
    NpgsqlLengthCache lengthCache
    NpgsqlParameter parameter
    Boolean async
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    TAnySubtype

    Implements

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