Skip to content Skip to sidebar Skip to footer

How Can I Use Transactionscope With Sql Compact 4.0 And Nhibernate

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 Co

Solution 1:

Your code potentially produces 2 transactions:

1)new TransactionScope(TranactionScopeOption.Required)
2)session.BeginTransaction()

TransactionScope.Required "uses an ambient transaction if one already exists. Otherwise, it creates a new transaction before entering the scope. This is the default value". Your are guaranteed to have an ambient transaction by time session.BeginTransaction() gets hit, hence, making it a nested transaction.

If the transaction scope is not completed everything within its scope will be rolled back.


Solution 2:

I think the answer lies in this question: The connection object can not be enlisted in transaction scope

"At a guess, TransactionScope needs to escalate to a distributed or nested transaction, neither of which is supported by CE."


Post a Comment for "How Can I Use Transactionscope With Sql Compact 4.0 And Nhibernate"