BulkImportPseudoTableType
This enum defines the type of pseudo-temporary table created during bulk-import operations. It applies only to the PostgreSQL RDBMS.
It is used by the following bulk import operations.
Enum Values
| Name | Description |
|---|---|
| Temporary | A temporary pseudo-table will be created. The table is dedicated to the session of the connection and is automatically being destroyed once the connection is closed/disposed. Use this if you are working within an asynchronous environment. |
| Physical | A physical pseudo-table will be created. The table is shared to any other connections. Use this if you prefer performance and is not working within an asynchronous environment. |
Usability
Pass the value to the pseudoTableType argument of the target operation.
For BinaryBulkDelete:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var deletedRows = connection.BinaryBulkDelete(people,
pseudoTableType: BulkImportPseudoTableType.Physical);
}
using (var connection = new NpgsqlConnection(connectionString))
{
var primaryKeys = GetPeople(1000).Select(e => e.Id);
var deletedRows = connection.BinaryBulkDeleteByKey(primaryKeys,
pseudoTableType: BulkImportPseudoTableType.Physical);
}
For BinaryBulkInsert:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var insertedRows = connection.BinaryBulkInsert(people,
pseudoTableType: BulkImportPseudoTableType.Physical);
}
For BinaryBulkMerge:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var mergedRows = connection.BinaryBulkMerge(people,
pseudoTableType: BulkImportPseudoTableType.Physical);
}
For BinaryBulkUpdate:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var updatedRows = connection.BinaryBulkUpdate(people,
pseudoTableType: BulkImportPseudoTableType.Physical);
}
By default, the
Temporaryis used and it is thread-safe in nature. The pseudo-temporary table that is being created is localized to the instance of the connection.