Class ArrayHandler<TElement>
Base class for all type handlers which handle PostgreSQL arrays.
Inherited Members
Namespace: Npgsql.Internal.TypeHandlers
Assembly: Npgsql.dll
Syntax
public class ArrayHandler<TElement> : ArrayHandler
Type Parameters
Name | Description |
---|---|
TElement |
Remarks
https://www.postgresql.org/docs/current/static/arrays.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
ArrayHandler(PostgresType, NpgsqlTypeHandler, ArrayNullabilityMode, Int32)
Declaration
public ArrayHandler(PostgresType arrayPostgresType, NpgsqlTypeHandler elementHandler, ArrayNullabilityMode arrayNullabilityMode, int lowerBound = 1)
Parameters
Type | Name | Description |
---|---|---|
PostgresType | arrayPostgresType | |
NpgsqlTypeHandler | elementHandler | |
ArrayNullabilityMode | arrayNullabilityMode | |
Int32 | lowerBound |
Methods
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
ValidateAndGetLengthCustom<TAny>(TAny, ref NpgsqlLengthCache, NpgsqlParameter)
Declaration
protected override int ValidateAndGetLengthCustom<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
ValidateObjectAndGetLength(Object, 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 shold be thrown. Also returns the byte length needed to write the value.
Declaration
public override int ValidateObjectAndGetLength(object value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
Type | Name | Description |
---|---|---|
Object | value | The value to be written to PostgreSQL |
NpgsqlLengthCache | lengthCache | If the byte length calculation is costly (e.g. for UTF-8 strings), its result can be stored in the length cache to be reused in the writing process, preventing recalculation. |
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. |
Overrides
WriteObjectWithLength(Object, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Writes a value to the provided buffer, using either sync or async I/O.
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 | The value to write. |
NpgsqlWriteBuffer | buf | The buffer to which to write. |
NpgsqlLengthCache | lengthCache | |
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 is required to read the full length of the value, whether it should be performed synchronously or asynchronously. |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is None. |
Returns
Type | Description |
---|---|
Task |
Overrides
WriteWithLengthCustom<TAny>(TAny, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, Boolean, CancellationToken)
Declaration
protected override Task WriteWithLengthCustom<TAny>(TAny value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
TAny | value | |
NpgsqlWriteBuffer | buf | |
NpgsqlLengthCache | lengthCache | |
NpgsqlParameter | parameter | |
Boolean | async | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
TAny |