How to catch SqlException caused by deadlock?
The Microsft SQL Server-specific error code for a deadlock is 1205 so you’d need to handle the SqlException and check for that. So, e.g. if for all other types of SqlException you want the bubble the exception up: catch (SqlException ex) { if (ex.Number == 1205) { // Deadlock } else throw; } Or, using … Read more