Class RangeHandler<TSubtype1, TSubtype2>
Type handler for PostgreSQL range types.
Inherited Members
Namespace: Npgsql.Internal.TypeHandlers
Assembly: Npgsql.dll
Syntax
public class RangeHandler<TSubtype1, TSubtype2> : RangeHandler<TSubtype1>, INpgsqlTypeHandler<NpgsqlRange<TSubtype1>>, INpgsqlTypeHandler<NpgsqlRange<TSubtype2>>
Type Parameters
Name | Description |
---|---|
TSubtype1 | The main range subtype. |
TSubtype2 | An alternative range subtype. |
Remarks
Introduced in PostgreSQL 9.2. https://www.postgresql.org/docs/current/static/rangetypes.html
Constructors
RangeHandler(PostgresType, NpgsqlTypeHandler)
Declaration
public RangeHandler(PostgresType rangePostgresType, NpgsqlTypeHandler subtypeHandler)
Parameters
Type | Name | Description |
---|---|---|
PostgresType | rangePostgresType | |
NpgsqlTypeHandler | subtypeHandler |
Methods
ValidateAndGetLength(NpgsqlRange<TSubtype2>, 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<TSubtype2> value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlRange<TSubtype2> | 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. |
ValidateObjectAndGetLength(Object, ref NpgsqlLengthCache, NpgsqlParameter)
Declaration
public 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
Write(NpgsqlRange<TSubtype2>, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer.
Declaration
public Task Write(NpgsqlRange<TSubtype2> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
NpgsqlRange<TSubtype2> | 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 |
WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
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 | |
NpgsqlWriteBuffer | buf | |
NpgsqlLengthCache | lengthCache | |
NpgsqlParameter | parameter | |
Boolean | async | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Overrides
Explicit Interface Implementations
INpgsqlTypeHandler<NpgsqlRange<TSubtype2>>.Read(NpgsqlReadBuffer, Int32, Boolean, FieldDescription)
Declaration
ValueTask<NpgsqlRange<TSubtype2>> INpgsqlTypeHandler<NpgsqlRange<TSubtype2>>.Read(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<TSubtype2>> |