dbMonitor and TransactionScope issue

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
mservidio
Posts: 14
Joined: Mon 26 Jul 2010 19:46

dbMonitor and TransactionScope issue

Post by mservidio » Wed 28 Jul 2010 15:57

Hi All -

I am using Entity Framework to do some inserts/updates into my database. When I create new Entity Objects and then call SaveChanges(), everything works and dbMonitor shows all of the executed commands. However, when I wrap this same code in a TransactionScope, none of the db activity is showing the dbMonitor. Does anyone know why this is happening, and how to get dbMonitor to show this?

thanks,
Mark

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 30 Jul 2010 11:56

I have just made a test and the SQL statements sent to database were correct.
I am using the latest 5.70.152 build of dotConnect for Oracle and DBMonitor 3.0.2. Here is the code I was using to reproduce the problem.
Could you please make changes in my code to reproduce the problem and post the changed code here?

Code: Select all

      OracleMonitor mon = new OracleMonitor();
      mon.TraceEvent += new Devart.Common.MonitorEventHandler(mon_TraceEvent);
      mon.IsActive = true;
      using (DataModel1Entities db = new DataModel1Entities()) {
        using (TransactionScope t = new TransactionScope()) {
          Dept d = new Dept
          {
            Deptno = 1,
            Dname = "montest",
            Loc = "montest"
          };
          db.AddToDepts(d);
          db.SaveChanges();
          t.Complete();
        }
      }

mservidio
Posts: 14
Joined: Mon 26 Jul 2010 19:46

Post by mservidio » Fri 30 Jul 2010 15:29

Previously I had created the OracleMonitor within the Initialization constructor for my Entities. With the dbMonitor created there, the dbMonitor was working for and showing all calls to the db, except it wasn't showing any commands sent to the db that were within a transactionscope.

I've moved the created of the OracleMonitor to within the method that has the transactionscope, and now the dbMonitor shows the activity.

One further question on this though, while I don't see an explicit transaction in the dbMonitor, when I wrap my code in a TransactionScope, does DevArt provider automatically create a transaction in oracle? Ie: if an exception is thrown in my code before getting to t.Complete(), should the transaction commit/rollback?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 30 Jul 2010 16:26

Glad to hear the issue is resolved.
As for your question, the distributed transaction is created in Oracle server, and it is rolled back in case it is not completed before the Dispose method is called on the TransactionScope instance.

mservidio
Posts: 14
Joined: Mon 26 Jul 2010 19:46

Post by mservidio » Fri 30 Jul 2010 16:39

Excellent. Thanks for the quick response!

Post Reply