Table of Contents

Class NpgsqlBinaryImporter

Namespace
Npgsql
Assembly
Npgsql.dll

Provides an API for a binary COPY FROM operation, a high-performance data import mechanism to a PostgreSQL table. Initiated by BeginBinaryImport(string)

public sealed class NpgsqlBinaryImporter : IDisposable
Inheritance
NpgsqlBinaryImporter
Implements
Inherited Members

Remarks

Methods

Close()

Completes the import process and signals to the database to write everything.

public void Close()

Complete()

Completes the import operation. The writer is unusable after this operation.

public void Complete()

Dispose()

Cancels that binary import and sets the connection back to idle state

public void Dispose()

StartRow()

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

public void StartRow()

WriteNull()

Writes a single null column value.

public void WriteNull()

WriteRow(params object[])

Writes an entire row of columns. Equivalent to calling StartRow(), followed by multiple Write<T>(T) on each value.

public void WriteRow(params object[] values)

Parameters

values object[]

An array of column values to be written as a single row

Write<T>(T)

Writes a single column in the current row.

public void Write<T>(T value)

Parameters

value T

The value to be written

Type Parameters

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.

public void Write<T>(T value, NpgsqlDbType npgsqlDbType)

Parameters

value T

The value to be written

npgsqlDbType NpgsqlDbType

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

Type Parameters

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.

public void Write<T>(T value, string dataTypeName)

Parameters

value T

The value to be written

dataTypeName string

In some cases T isn't enough to infer the data type to be written to the database. This parameter and be used to unambiguously specify the type.

Type Parameters

T

The .NET type of the column to be written.