by grandpoobah · 8y ago · 0 comments
seriously?
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.
ex.InnerException.Message.IndexOf("duplicate", StringComparison.OrdinalIgnoreCase) > -1
Good idea would also be to check for existence of Inner exception at all ex.InnerException?.Message.IndexOf("duplicate", StringComparison.OrdinalIgnoreCase) > -1
But I would just live without that check to prevent magical behavior.I done a fair bit of performance problem fixing now in my career and I have never seen a .ToLower be the cause of any client's performance problems. Or really any string manipulation opinion like stringbuilder vs += and all that nonsense.
I don't believe it is useful to save a trip to the database, the database is there for a reason.