Class NpgsqlBinaryImporter
Provides an API for a binary COPY FROM operation, a high-performance data import mechanism to a PostgreSQL table. Initiated by BeginBinaryImport(String)
Implements
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public sealed class NpgsqlBinaryImporter : object
Remarks
Properties
| Improve this Doc View SourceTimeout
Current timeout
Declaration
public TimeSpan Timeout { set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
| Improve this Doc View SourceClose()
Terminates the ongoing binary import and puts the connection back into the idle state, where regular commands can be executed.
Note that if Complete() hasn't been invoked before calling this, the import will be cancelled and all changes will be reverted.
Declaration
public void Close()
CloseAsync(CancellationToken)
Async terminates the ongoing binary import and puts the connection back into the idle state, where regular commands can be executed.
Note that if CompleteAsync(CancellationToken) hasn't been invoked before calling this, the import will be cancelled and all changes will be reverted.
Declaration
public ValueTask CloseAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
ValueTask |
Complete()
Completes the import operation. The writer is unusable after this operation.
Declaration
public ulong Complete()
Returns
Type | Description |
---|---|
UInt64 |
CompleteAsync(CancellationToken)
Completes the import operation. The writer is unusable after this operation.
Declaration
public ValueTask<ulong> CompleteAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
ValueTask<UInt64> |
Dispose()
Terminates the ongoing binary import and puts the connection back into the idle state, where regular commands can be executed.
Note that if Complete() hasn't been invoked before calling this, the import will be cancelled and all changes will be reverted.
Declaration
public void Dispose()
DisposeAsync()
Async terminates the ongoing binary import and puts the connection back into the idle state, where regular commands can be executed.
Note that if CompleteAsync(CancellationToken) hasn't been invoked before calling this, the import will be cancelled and all changes will be reverted.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
StartRow()
Starts writing a single row, must be invoked before writing any columns.
Declaration
public void StartRow()
StartRowAsync(CancellationToken)
Starts writing a single row, must be invoked before writing any columns.
Declaration
public Task StartRowAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Write<T>(T)
Writes a single column in the current row.
Declaration
public void Write<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
Type Parameters
Name | Description |
---|---|
T | The type of the column to be written. This must correspond to the actual type or data corruption will occur. If in doubt, use Write<T>(T, NpgsqlDbType) to manually specify the type. |
Write<T>(T, NpgsqlDbType)
Writes a single column in the current row as type npgsqlDbType
.
Declaration
public void Write<T>(T value, NpgsqlDbType npgsqlDbType)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
NpgsqlDbType | npgsqlDbType | In some cases |
Type Parameters
Name | Description |
---|---|
T | The .NET type of the column to be written. |
Write<T>(T, String)
Writes a single column in the current row as type dataTypeName
.
Declaration
public void Write<T>(T value, string dataTypeName)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
String | dataTypeName | In some cases |
Type Parameters
Name | Description |
---|---|
T | The .NET type of the column to be written. |
WriteAsync<T>(T, CancellationToken)
Writes a single column in the current row.
Declaration
public Task WriteAsync<T>(T value, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T | The type of the column to be written. This must correspond to the actual type or data corruption will occur. If in doubt, use Write<T>(T, NpgsqlDbType) to manually specify the type. |
WriteAsync<T>(T, NpgsqlDbType, CancellationToken)
Writes a single column in the current row as type npgsqlDbType
.
Declaration
public Task WriteAsync<T>(T value, NpgsqlDbType npgsqlDbType, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
NpgsqlDbType | npgsqlDbType | In some cases |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T | The .NET type of the column to be written. |
WriteAsync<T>(T, String, CancellationToken)
Writes a single column in the current row as type dataTypeName
.
Declaration
public Task WriteAsync<T>(T value, string dataTypeName, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be written |
String | dataTypeName | In some cases |
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T | The .NET type of the column to be written. |
WriteNull()
Writes a single null column value.
Declaration
public void WriteNull()
WriteNullAsync(CancellationToken)
Writes a single null column value.
Declaration
public Task WriteNullAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
WriteRow(Object[])
Writes an entire row of columns. Equivalent to calling StartRow(), followed by multiple Write<T>(T) on each value.
Declaration
public void WriteRow(params object[] values)
Parameters
Type | Name | Description |
---|---|---|
Object[] | values | An array of column values to be written as a single row |
WriteRowAsync(CancellationToken, Object[])
Writes an entire row of columns. Equivalent to calling StartRow(), followed by multiple Write<T>(T) on each value.
Declaration
public Task WriteRowAsync(CancellationToken cancellationToken = null, params object[] values)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | An optional token to cancel the asynchronous operation. The default value is |
Object[] | values | An array of column values to be written as a single row |
Returns
Type | Description |
---|---|
Task |