I have a block of code wrapped in a transaction scope. I’m using LINQ to communicate with the database. Once I capture a deadlock exception, how do I resubmit the transaction?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically, you just catch the deadlock exception and try the code again. We do something like this:
And the call looks like this:
Note that the Execute() method eventually calls ExecuteWithDeadlockRetry(). There is a bit more to our solution than what you’re asking, but this should give you some general direction.