diff --git a/MySQLConnector/Connection.cs b/MySQLConnector/Connection.cs index d293a6d..df0fdd4 100644 --- a/MySQLConnector/Connection.cs +++ b/MySQLConnector/Connection.cs @@ -10,7 +10,7 @@ namespace FLocal.MySQLConnector { public class Connection : IDBConnection { - private IDBTraits traits; + internal readonly IDBTraits traits; private DbConnection connection; private string connectionString; diff --git a/MySQLConnector/IDBTraits.cs b/MySQLConnector/IDBTraits.cs index b9a6d1a..e1c4f64 100644 --- a/MySQLConnector/IDBTraits.cs +++ b/MySQLConnector/IDBTraits.cs @@ -16,5 +16,7 @@ namespace FLocal.MySQLConnector { string markParam(string param); + bool supportsIsolationLevel(); + } } diff --git a/MySQLConnector/MySQLDBTraits.cs b/MySQLConnector/MySQLDBTraits.cs index 7cb10ef..7333f7f 100644 --- a/MySQLConnector/MySQLDBTraits.cs +++ b/MySQLConnector/MySQLDBTraits.cs @@ -27,5 +27,10 @@ namespace FLocal.MySQLConnector { return "@" + param; } + public bool supportsIsolationLevel() { + //for some reason, call to BeginTransaction with IsolationLevel set fails somewhere deep in mysql library + return false; + } + } } diff --git a/MySQLConnector/PostgresDBTraits.cs b/MySQLConnector/PostgresDBTraits.cs index a11120d..067aef1 100644 --- a/MySQLConnector/PostgresDBTraits.cs +++ b/MySQLConnector/PostgresDBTraits.cs @@ -35,5 +35,9 @@ namespace FLocal.MySQLConnector { return ":" + param; } + public bool supportsIsolationLevel() { + return true; + } + } } diff --git a/MySQLConnector/Transaction.cs b/MySQLConnector/Transaction.cs index 5d2d224..dbd17a3 100644 --- a/MySQLConnector/Transaction.cs +++ b/MySQLConnector/Transaction.cs @@ -19,8 +19,11 @@ namespace FLocal.MySQLConnector { public Transaction(Connection connection, System.Data.IsolationLevel iso) : base() { this.sqlconnection = connection.createConnection(); try { - //for some reason, call to BeginTransaction with IsolationLevel set fails somewhere deep in mysql library - this.sqltransaction = this.sqlconnection.BeginTransaction(); + if(connection.traits.supportsIsolationLevel()) { + this.sqltransaction = this.sqlconnection.BeginTransaction(iso); + } else { + this.sqltransaction = this.sqlconnection.BeginTransaction(); + } } catch(Exception e) { this.close(); throw e;