RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Enhancement: Allow only updating changed records during BulkMerge

Open jgranger36 opened this issue 3 years ago • 1 comments
trafficstars

Describe the enhancement

Allow only updating changed records during BulkMerge. This will eliminate unneeded writes to the table and preserve any modified date column. This maintains the efficiency of the sqlbulkcopy to a temp table for data transfer but allows more granularity in what modifications actually happen against the table.

               _connection.BulkMergeAsync<SomeObject>(entities, qualifiers,mappings,additionalQualifiers);

Additional Context

I think the easiest way is to simply have another parameter for additionalQualifiers that will add additional WHERE/OR clauses to the query, comparing these columns from source and destination tables and only updating where values do not match.

jgranger36 avatar Jul 10 '22 14:07 jgranger36

@jgranger36 - by design, RepoDB's does not have State Tracking functionalities and could not track any changes made to the data/row. With this, the possibility of updating only which data/row via BulkMerge is not possible. This is also true if you are using any Merge operations (i.e: MergeAll & Merge).

On the other hand, we pre-assume that your intention is to update the records, not merging it. Would you be able to utilize the BulkUpdate instead?

I think the easiest way is to simply have another parameter for additionalQualifiers that will add additional WHERE/OR clauses to the query, comparing these columns from source and destination tables and only updating where values do not match.

The MERGE functionality on the SQL Server is to INSERT/UPDATE/DELETE the data/row via the given qualitiers within the MERGE INTO statement. Those qualifiers can be extended via the qualifiers argument when calling the BulkMerge operation. Additional filter bindings to which data/row to MERGE are not possible.

mikependon avatar Jul 11 '22 07:07 mikependon