I had a problem when a transaction is not rolled back when using TransactionScope.
We use NHibernate with an in-memory SQLite database, so this limits only one db connection throughout the life 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();
}
}
Even if I delete the NHibernate internal nested transaction, so the code is just below, the transaction is still executing.
using (var ts = new TransactionScope(TransactionScopeOption.Required,
TimeSpan.Zero))
{
_repository.Save(entity);
}
Is a recently opened SQLite connection expected inside a block TransactionScopeto enlist it in a transaction?
Again, I cannot provide it with a new connection because this will clear the database.
Using NHibernate 3.0 and SQLite 1.0.66.0, both latest versions at the time of writing.
:, transaction.Rollback() NHibernate ITransaction, , TransactionScope, , , .