PostgreSqlBulkImportPseudoTableType
This enum was previously named
BulkImportPseudoTableType. That name is now deprecated in favor ofPostgreSqlBulkImportPseudoTableTypeand will be tagged starting v1.16.0 of theRepoDb.PostgreSqlandRepoDb.PostgreSql.BulkOperationspackages.
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 BulkDelete:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var deletedRows = connection.BulkDelete(people,
pseudoTableType: PostgreSqlBulkImportPseudoTableType.Physical);
}
For BulkDeleteByKey:
using (var connection = new NpgsqlConnection(connectionString))
{
var primaryKeys = GetPeople(1000).Select(e => e.Id);
var deletedRows = connection.BulkDeleteByKey(primaryKeys,
pseudoTableType: PostgreSqlBulkImportPseudoTableType.Physical);
}
For BulkInsert:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var insertedRows = connection.BulkInsert(people,
pseudoTableType: PostgreSqlBulkImportPseudoTableType.Physical);
}
For BulkMerge:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var mergedRows = connection.BulkMerge(people,
pseudoTableType: PostgreSqlBulkImportPseudoTableType.Physical);
}
For BulkUpdate:
using (var connection = new NpgsqlConnection(connectionString))
{
var people = GetPeople(1000);
var updatedRows = connection.BulkUpdate(people,
pseudoTableType: PostgreSqlBulkImportPseudoTableType.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.