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 : IDisposable, IAsyncDisposable
Remarks
Properties
| Improve this Doc View SourceTimeout
Current timeout
Declaration
public TimeSpan Timeout { set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Remarks
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()
Remarks
| Improve this Doc View SourceCloseAsync(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 |
Remarks
| Improve this Doc View SourceComplete()
Completes the import operation. The writer is unusable after this operation.
Declaration
public ulong Complete()
Returns
Type | Description |
---|---|
ulong |
Remarks
| Improve this Doc View SourceCompleteAsync(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<><ulong> |
Remarks
| Improve this Doc View SourceDispose()
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()
Remarks
| Improve this Doc View SourceDisposeAsync()
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 |
Remarks
| Improve this Doc View SourceStartRow()
Starts writing a single row, must be invoked before writing any columns.
Declaration
public void StartRow()
Remarks
| Improve this Doc View SourceStartRowAsync(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 |
Remarks
| Improve this Doc View SourceWrite<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. |
Remarks
| Improve this Doc View SourceWrite<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. |
Remarks
| Improve this Doc View SourceWrite<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. |
Remarks
| Improve this Doc View SourceWriteAsync<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. |
Remarks
| Improve this Doc View SourceWriteAsync<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. |
Remarks
| Improve this Doc View SourceWriteAsync<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. |
Remarks
| Improve this Doc View SourceWriteNull()
Writes a single null column value.
Declaration
public void WriteNull()
Remarks
| Improve this Doc View SourceWriteNullAsync(CancellationToken)
Writes a single null column value.
Declaration
public Task WriteNullAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Remarks
| Improve this Doc View SourceWriteRow(params 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 |
Remarks
| Improve this Doc View SourceWriteRowAsync(CancellationToken, params 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 |