In our code base the connection to the underlying provider is more or less hidden from the developer at all times such that he/she won't have to worry about it.
This includes cases where we need to do multiple things in a transaction.
We have a helper method that looks something like this:
Code: Select all
public IDbTransaction CreateTransaction()
{
var connection = this.connectionManager.CreateConnection();
connection.Open(),
return connection.BeginTransaction()
}
Code: Select all
using(var transaction = repository.CreateTransaction())
{
// Do transaction stuff
transaction.Commit();
}
However because the dotConnect provider does something on "Commit" along the lines of:
Code: Select all
this.Connection = null;
So basically we now have to remember to do the following all the places we use transactions
Code: Select all
using(var transaction = repository.CreateTransaction())
using(var connection = transaction.Connection)
{
// Do transaction stuff
transaction.Commit();
}
Any chance you are going to change the behavior or will we have to write some sort of analyzer for our code to avoid connection leaks in the future?