This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, This may be a stupid question; I know you can change the database provider to another database type just by changing the configuration file, but what should I do about exceptions? By way of example: I am currently using MySql5 provider and if the database server is unavailable then a MySql5 specific exception is thrown - not some generic database connection error. So if I handle that scenario and then change to SQL provider then that connection error will not be handled. So is there a way to have the UOW throw a generic database connection error exception? Thanks Scott |
|
|
For most scenarios, you can catch System.Data.Common.DbException. This is the base class for SqlException and OracleException in the .NET Framework, and for all providers exceptions in the databases we support, apart from the Oracle ODP driver. If you also need to support ODP, you'll need to catch Exception and write a little helper method to determine if it's a database exception: internal static bool IsDatabaseException(this Exception ex) { And your catch clauses will then check this and rethrow non-database exceptions: if (ex.IsDatabaseException() { (If you are using Visual Basic you can do this with an exception filter which is syntactically nicer.) |
|
|
Wow thanks, that's perfect exactly what I am looking for. ;) Thanks again for all the hard work that goes into this product, greatly appreciated. - Scott |
|