I'm running into a problem where a transaction does not roll back when using TransactionScope.
We're using NHibernate with an in memory SQLite database, so that limits us to just one db connection for the duration of the entire lifetime of the application (in this case, some unit tests).
using (var ts = new TransactionScope(TransactionScopeOption.Required,
TimeSpan.Zero))
{
using (var transaction = _repository.BeginTransaction())
{
_repository.Save(entity);
transaction.Commit();
}
// ts.Complete(); <- commented Complete call still commits transaction
}
Even if I remove NHibernate's inner nested transaction so the code is simply as below, the transaction is still commited.
using (var ts = new TransactionScope(TransactionScopeOption.Required,
TimeSpan.Zero))
{
_repository.Save(entity);
} // no Complete(), but the transaction still commits
Is it expecting a freshly opened SQLite connection inside the TransactionScope block in order to enlist it in the transaction?
Again, I can't supply it with a new connection because that would clear out the database.
Using NHibernate 3.0 and SQLite 1.0.66.0, both latest versions at the time of writing.
Note: using transaction.Rollback() on the NHibernate ITransaction object correctly rolls back the transaction, it's just the TransactionScope support that doesn't seem to work.