Table of Contents

Class NpgsqlBinaryExporter

Namespace
Npgsql
Assembly
Npgsql.dll

Provides an API for a binary COPY TO operation, a high-performance data export mechanism from a PostgreSQL table. Initiated by BeginBinaryExport(string)

public sealed class NpgsqlBinaryExporter : IDisposable, IAsyncDisposable
Inheritance
NpgsqlBinaryExporter
Implements
Inherited Members

Properties

IsNull

Returns whether the current column is null.

public bool IsNull { get; }

Property Value

bool

Timeout

Current timeout

public TimeSpan Timeout { set; }

Property Value

TimeSpan

Methods

Cancel()

Cancels an ongoing export.

public void Cancel()

CancelAsync()

Async cancels an ongoing export.

public Task CancelAsync()

Returns

Task

Dispose()

Completes that binary export and sets the connection back to idle state

public void Dispose()

DisposeAsync()

Async completes that binary export and sets the connection back to idle state

public ValueTask DisposeAsync()

Returns

ValueTask

ReadAsync<T>(NpgsqlDbType, CancellationToken)

Reads the current column, returns its value according to type and moves ahead to the next column. If the column is null an exception is thrown.

public ValueTask<T> ReadAsync<T>(NpgsqlDbType type, CancellationToken cancellationToken = default)

Parameters

type NpgsqlDbType

In some cases T isn't enough to infer the data type coming in from the database. This parameter can be used to unambiguously specify the type. An example is the JSONB type, for which T will be a simple string but for which type must be specified as Jsonb.

cancellationToken CancellationToken

An optional token to cancel the asynchronous operation. The default value is None.

Returns

ValueTask<T>

The value of the column

Type Parameters

T

The .NET type of the column to be read.

ReadAsync<T>(CancellationToken)

Reads the current column, returns its value and moves ahead to the next column. If the column is null an exception is thrown.

public ValueTask<T> ReadAsync<T>(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<T>

The value of the column

Type Parameters

T

The type of the column to be read. This must correspond to the actual type or data corruption will occur. If in doubt, use Read<T>(NpgsqlDbType) to manually specify the type.

Read<T>()

Reads the current column, returns its value and moves ahead to the next column. If the column is null an exception is thrown.

public T Read<T>()

Returns

T

The value of the column

Type Parameters

T

The type of the column to be read. This must correspond to the actual type or data corruption will occur. If in doubt, use Read<T>(NpgsqlDbType) to manually specify the type.

Read<T>(NpgsqlDbType)

Reads the current column, returns its value according to type and moves ahead to the next column. If the column is null an exception is thrown.

public T Read<T>(NpgsqlDbType type)

Parameters

type NpgsqlDbType

In some cases T isn't enough to infer the data type coming in from the database. This parameter can be used to unambiguously specify the type. An example is the JSONB type, for which T will be a simple string but for which type must be specified as Jsonb.

Returns

T

The value of the column

Type Parameters

T

The .NET type of the column to be read.

Skip()

Skips the current column without interpreting its value.

public void Skip()

SkipAsync(CancellationToken)

Skips the current column without interpreting its value.

public Task SkipAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

StartRow()

Starts reading a single row, must be invoked before reading any columns.

public int StartRow()

Returns

int

The number of columns in the row. -1 if there are no further rows. Note: This will currently be the same value for all rows, but this may change in the future.

StartRowAsync(CancellationToken)

Starts reading a single row, must be invoked before reading any columns.

public ValueTask<int> StartRowAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<int>

The number of columns in the row. -1 if there are no further rows. Note: This will currently be the same value for all rows, but this may change in the future.