How prevent duplicate record when using WEB API. I call WEB API with double click or more click and i get duplicate record in DB. Then i debugging, pointer is "jumping" from one place to another. I am checking are record already is in DB, but its not working with multiple thread.
Asked
Active
Viewed 774 times
-4
-
You need to implement transactions, locks to coordinate concurrent access – Khanh TO Feb 23 '15 at 12:35
-
"in DB"? Which DB? How do you address the DB? Entity Framework perhaps? You need to tell us this information so that we aren't guessing. – spender Feb 23 '15 at 12:48
1 Answers
0
Get your database schema right in the first place. No duplicates allowed? Then you need to implement a unique constraint in your database that disallows duplicates. Then the situation you describe becomes impossible and the second commit results in an error.