
subsonicproject - issue #95
DbDataProvider does not take SharedConnection into account on ExecuteXXX methods in version 3.0
I'm using the System.Transactions namespace to enforce a transaction on multiple actions.
To ensure that the same DbConnection is used, I am creating an SharedDbConnectionScope instance "around" the statements, much like the following code (that I took from yours SqlQuery class):
public static void ExecuteTransaction(List<SqlQuery> queries) { using (new SharedDbConnectionScope()) { using (new TransactionScope()) { foreach (SqlQuery query in queries) { query.Execute(); } } } }
The problem is that MSDTC "fires" anyway...
SqlQuery objects "dispatch" their execute methods to their associated data provider's corresponding Execute method.
I saw the code of the DBDataProvider and, for example, ExecuteQuery and ExecuteScalar, both create new connections, ignoring the CurrentSharedConnection in effect on that same data provider.
This is a shame for me and the project I am working on cause we have no other way to change this behaviour. Do You know Of Any? If we had the source code we could recompile it with the fix.
Comment #1
Posted on Jun 4, 2009 by Happy RhinoI'm sure you wanted to posth this issue to http://code.google.com/p/subsonicthree/issues/list ;-)
Anyway, I think you have to wrap the TransactionScope around the SharedDbConnectionScope.
To explicitly force a new Transaction you can add the RequireNew option:
using (TransactionScope ts = new
TransactionScope(TransactionScopeOption.RequiresNew)) {
}
Comment #2
Posted on Jun 4, 2009 by Quick MonkeyThanks I will post this issue in that project. Anyway, now I know the source code is available so I may change and recompile in the mean-time.
Status: New
Labels:
Type-Defect
Priority-Medium