Show / Hide Table of Contents

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)

Inheritance
System.Object
NpgsqlBinaryImporter
Implements
IDisposable
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public sealed class NpgsqlBinaryImporter : object, ICancelable, IDisposable
Remarks

See http://www.postgresql.org/docs/current/static/sql-copy.html.

Methods

Cancel()

Cancels and terminates an ongoing import. Any data already written will be discarded.

Declaration
public void Cancel()

Close()

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

Declaration
public void Close()

Dispose()

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

Declaration
public void Dispose()

StartRow()

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

Declaration
public void StartRow()

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 type.

Declaration
public void Write<T>(T value, NpgsqlDbType type)
Parameters
Type Name Description
T value

The value to be written

NpgsqlDbType type

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 type must be specified as Jsonb.

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()

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
System.Object[] values

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

Implements

IDisposable
Back to top Copyright © 2015-2017 Microsoft
Generated by DocFX