I am trying to use NHibernate in combination with .NET's TransactionScope object. So far I have successfully used Oracle 11g and SQL Server 2008R2 with no issues. However, SQL Compact seems to fall on its face.
using (var scope = new TransactionScope(TranactionScopeOption.Required))
{
using (var session = _sessionFactory.OpenSession())
{
// The line below throws. I also tried passing in System.Data.IsolationLevel.ReadCommitted to no avail
using (var txn = session.BeginTransaction())
{
// Perform insert
txn.Commit();
}
}
scope.Complete();
}
This results in the following exception. I understand what this means, but I don't understand why it is attempting to create a nested transaction.
NHibernate.TransactionException: Begin failed with SQL exception ---> System.InvalidOperationException: SqlCeConnection does not support nested transactions.
at System.Data.SqlServerCe.SqlCeConnection.BeginTransaction(IsolationLevel isolationLevel)
at System.Data.SqlServerCe.SqlCeConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction(IsolationLevel isolationLevel)
at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)
at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)