Link Search Menu Expand Document

SapHanaBulkImportIdentityBehavior


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

Enum Values

NameDescription
KeepIdentityThe value of the identity property/column will be kept and used. (This is the default value)
ReturnIdentityThe newly generated identity value from the target table will be set back to the entity.

There is no Unspecified state — this enum defaults straight to KeepIdentity, the same shape as Db2BulkImportIdentityBehavior, FirebirdBulkImportIdentityBehavior, and VerticaBulkImportIdentityBehavior.

ReturnIdentity’s identity computation — a client-computed “next identity = MAX(identity) + 1” seeded value, combined with row-order arithmetic for BulkInsert, and a three-step matched/unmatched assignment for BulkMerge — is the least-verified part of the whole provider (per the source’s own remarks). Verify it carefully, especially under concurrent writers to the same table, before relying on it in production.

Usability

This enum is used by both the BulkInsert and BulkMerge operations of RepoDb.SapHana.BulkOperations. Pass the value to the identityBehavior argument when calling the operation.

For BulkInsert:

using (var connection = new HanaConnection(connectionString))
{
    var people = GetPeople(1000);
    var insertedRows = connection.BulkInsert(people,
        identityBehavior: SapHanaBulkImportIdentityBehavior.ReturnIdentity);
}

For BulkMerge:

using (var connection = new HanaConnection(connectionString))
{
    var people = GetPeople(1000);
    var mergedRows = connection.BulkMerge(people,
        identityBehavior: SapHanaBulkImportIdentityBehavior.ReturnIdentity);
}