Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

TransactionScope use with NHContext #23

Closed lnu closed 6 years ago

lnu commented 9 years ago

We use breeze with NHibernate and Oracle. As recommended in the doc, we set TransactionType to TransactionType.DbTransaction. We set enlist=true in the connectionstring. But now, we also use NServicebus. In order to have both msmq and db in the same transaction, we changed TransactionType to TransactionType.TransactionScope. Out of the box, it didn't work throwing this exceptionConnection is already part of a local or a distributed transaction. To make it work, I removed the code related to transaction inside NHContext. I don't know exactly what it was supposed to do, as this code is already part of the transaction started in the ContextProvider. The code is still needed if no TransactionSettings is set(None). Now it works, with both types of Transactions. Do you see any issues with that?

NB: setting enlist=dynamic seems to work with the initial code. BUT, if an exception occurs the data are not rollbacked. Looking at Oracle docs, dynamic means you have to enlist the transaction by yourself. So it's not the solution

NB2: The changes works well... but we're also using envers and it works only with Oracle and not with Sql Server

NB3: The issue spans over breeze and nhibernate... I'll try to see with NHibernate people what's the best solution