zzzprojects / Bulk-Operations

C# SQL Bulk Operations | High-performance C# bulk insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL, and SQLite.
https://bulk-operations.net
142 stars 36 forks source link

usage of composite automapkeynames #44

Closed sagsgr8 closed 5 years ago

sagsgr8 commented 5 years ago

Hi,

We require to use the multiple key mapping (How to assign multiple/group of automapkeyname) in bulk merge operation.

We want to check multiple combination of columns to validate while uploading data. If record exist then it should check for combination of multiple columns & then update the existing record.

JonathanMagnan commented 5 years ago

Hello @sagsgr8 ,

Thank you for reporting, we will look at it.

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @sagsgr8 ,

It's possible to use a composite key by separating each column with a semicolon

operation.AutoMapKeyName = "ColumnIntTest;ColumnStringTest";

However, I'm not sure that's what you are looking for.

Are you asking to be able to provide multiple key combinations?

For example:

And the join clause will look something like this:

ON DestinationTable.ID = StagingTable.ID
OR (DestinationTable.Code = StagingTable.Code AND DestinationTable.Email = StagingTable.Email)

If that's the case, do you mind if you need to hardcode the previous SQL? It might be more flexible on your side for this special case than having to create some group.

coccor commented 4 years ago

operation.AutoMapKeyName = "ColumnIntTest;ColumnStringTest"; This should be in the documentation.