Hacker News new | ask | show | jobs
by caleblloyd 3058 days ago
I do not know of a good Cross DB solution. It may be more elegant to check specific exception types for the DBMSs that you do use. For example, MySQL would be:

https://github.com/mysql-net/MySqlConnector/blob/master/src/...

Check that MySqlException.Number == 1062 for Duplicate entry.

Add one check per DBMS that you use.