Class ByteaHandler
- Namespace
- Npgsql.TypeHandlers
- Assembly
- Npgsql.dll
public class ByteaHandler : NpgsqlTypeHandler<byte[]>, INpgsqlTypeHandler<byte[]>, INpgsqlTypeHandler<ArraySegment<byte>>
- Inheritance
-
ByteaHandler
- Implements
- Inherited Members
-
NpgsqlTypeHandler<byte[]>.Write(byte[], NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Remarks
Constructors
ByteaHandler()
public ByteaHandler()
Methods
Read(NpgsqlReadBuffer, int, bool, FieldDescription)
Reads a value of type TDefault with the given length from the provided buffer,
using either sync or async I/O.
public override ValueTask<byte[]> Read(NpgsqlReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
Parameters
bufNpgsqlReadBufferThe buffer from which to read.
lenintThe byte length of the value. The buffer might not contain the full length, requiring I/O to be performed.
asyncboolIf I/O is required to read the full length of the value, whether it should be performed synchronously or asynchronously.
fieldDescriptionFieldDescriptionAdditional PostgreSQL information about the type, such as the length in varchar(30).
Returns
- ValueTask<byte[]>
The fully-read value.
ValidateAndGetLength(ArraySegment<byte>, 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.
public int ValidateAndGetLength(ArraySegment<byte> value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
valueArraySegment<byte>The value to be written to PostgreSQL
lengthCacheNpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameterNpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
Returns
- int
The number of bytes required to write the value.
ValidateAndGetLength(byte[], ref NpgsqlLengthCache, NpgsqlParameter)
Called to validate and get the length of a value of a generic NpgsqlParameter<T>.
public override int ValidateAndGetLength(byte[] value, ref NpgsqlLengthCache lengthCache, NpgsqlParameter parameter)
Parameters
valuebyte[]lengthCacheNpgsqlLengthCacheparameterNpgsqlParameter
Returns
Write(ArraySegment<byte>, NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Writes a value to the provided buffer.
public Task Write(ArraySegment<byte> value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
valueArraySegment<byte>The value to write.
bufNpgsqlWriteBufferThe buffer to which to write.
lengthCacheNpgsqlLengthCacheA cache where the length calculated during the validation phase can be stored for use at the writing phase.
parameterNpgsqlParameterThe NpgsqlParameter instance where this value resides. Can be used to access additional information relevant to the write process (e.g. Size).
asyncboolIf I/O will be necessary (i.e. the buffer is full), determines whether it will be done synchronously or asynchronously.
Returns
Write(byte[], NpgsqlWriteBuffer, NpgsqlLengthCache, NpgsqlParameter, bool)
Called to write the value of a generic NpgsqlParameter<T>.
public override Task Write(byte[] value, NpgsqlWriteBuffer buf, NpgsqlLengthCache lengthCache, NpgsqlParameter parameter, bool async)
Parameters
valuebyte[]bufNpgsqlWriteBufferlengthCacheNpgsqlLengthCacheparameterNpgsqlParameterasyncbool