Sergey, thanks for your replay.
Maybe I didn’t explain well yesterday.
I’m going to give you an example because it is easier to understand
1) In the following example the database transaction is promoted to DTC
Try
Using trScope As TransactionScope = New TransactionScope(TransactionScopeOption.Required)
For i As Integer = 4 To 6
Dim miPais As New CO.Pais()
miPais.Codigo = "O" + i.ToString
miPais.Descripcion = "Test trans " + i.ToString
miPais.Id = 0
DA.PaisDA.grabar(session, miPais)
Next
trScope.Complete()
End Using
Catch eX As Exception
End Try
In the this example PaisDA.Grabar executes the following code
Public Shared Sub grabar(ByVal session As ISession, ByVal miPais As CO.Pais)
Dim Transaction As ITransaction
Transaction = Nothing
If Not session Is Nothing Then
Try
Transaction = session.BeginTransaction()
session.SaveOrUpdate(miPais)
Transaction.Commit()
Exit Try
Catch
If Not Transaction Is Nothing Then Transaction.Rollback()
session.Clear()
Throw
Exit Try
End Try
End If
End Sub
2) Now, I’m going to write an example where the database transaction isn’t promoted to DTC
Try
DA.PaisDA.consultar(session)
Using trScope As TransactionScope = New TransactionScope(TransactionScopeOption.Required)
For i As Integer = 4 To 6
Dim miPais As New CO.Pais()
miPais.Codigo = "O" + i.ToString
miPais.Descripcion = "Test trans " + i.ToString
miPais.Id = 0
DA.PaisDA.grabar(session, miPais)
Next
trScope.Complete()
End Using
Catch eX As Exception
End Try
In this case I’m using the nhibernate session to get the Provincias as follows
Public Shared Sub consultar(ByVal session As ISession)
Dim query As String
query = "from CO.Provincias as Provincias "
session.Find(query)
End Sub
Well, in the last example you can see that I’m not starting a database transaction before starting a DTC transaction I’m just using the nhibernate session to get Provincias without creating a new transaction, but after that, when I start a new transaction within a DTC transaction it isn’t promoted to DTC transaction.
Do you know why it happens?
Thanks, Martin
|