-
-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when inserting the same row more than once #112
Comments
That's precisely what InsertOrUpdate method does.
|
Boris,
I'm using the InsertOrUpdate method. However, I know that I have a number of duplicate records in my array that already have the ContactId set. The error message states 'A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times'. I'm not saying this is an error with BulkExtensions but do you have a suggestion to deal with this please?
Thanks
Tim
…________________________________
From: Boris Djurdjevic <[email protected]>
Sent: 13 December 2018 14:23:57
To: borisdj/EFCore.BulkExtensions
Cc: Tim Metcalfe; Author
Subject: Re: [borisdj/EFCore.BulkExtensions] Error when inserting the same row more than once (#112)
That's precisely what InsertOrUpdate method does.
As said in ReadMe:
BulkInsertOrUpdate method can be used when there is need for both operations but in one connection to database.
It makes Update when PK(PrimaryKey) is matched, otherwise does Insert.
Additionaly there is UpdateByProperties for specifying custom properties, by which we want update to be done.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#112 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AQoMa2RCb0RuogC9t3k5CH1aq7Hq_dRKks5u4mL9gaJpZM4ZRj7o>.
|
Consistency of data rests on input, so I can only agree with the way you already suggested which is to make a method that will first filter out duplicates, since library currently does not handle this. |
Hi,
Sometimes duplicate rows may exist in the data I'm inserting or updating. When there are duplicate rows, the following error is generated:
'SqlException: The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.'
I could check the data and remove the duplicate rows but would rather it was handled automatically. Is there a way for BulkExtensions to just insert or update one of the duplicate rows?
Thanks
Tim
The text was updated successfully, but these errors were encountered: