Link Search Menu Expand Document

ClickHouseBulkImportIdentityBehavior


This enum defines the behavior of the identity property/column when an entity is bulk-imported into a target table. It applies to RepoDb.ClickHouse.BulkOperations.

Enum Values

NameDescription
KeepIdentityThe identity/key value is written to the target table exactly as supplied on the entity. This is the only supported behavior, and the default.
ReturnIdentityNot supported. ClickHouse has no session-wide scope identity, sequence, or auto-increment mechanism, so requesting this value throws a NotSupportedException.

Usability

This enum is used by both the BulkInsert and BulkMerge operations. Since KeepIdentity is the default, most callers never need to pass it explicitly.

using (var connection = new ClickHouseConnection(connectionString))
{
    var people = GetPeople(1000);
    var insertedRows = connection.BulkInsert(people,
        identityBehavior: ClickHouseBulkImportIdentityBehavior.KeepIdentity);
}

Passing identityBehavior: ClickHouseBulkImportIdentityBehavior.ReturnIdentity to BulkInsert or BulkMerge always throws NotSupportedException — ClickHouse has no mechanism to generate or return identity values. Assign key values on the entity yourself before calling either operation.