I seem to have a problem when doing inserts within the context of a transaction, using TransactionScope.
I'm using a simple model with 2 tables: View en ViewLayout. There's a foreign key from ViewLayout to View.
This is the code to do an insert into View & ViewLayout within a transaction (DB is the datacontext):
Code: Select all
using (var scope = new TransactionScope())
{
using (var db = new DB())
{
var v = new View();
v.ViewID = Guid.NewGuid();
v.Name = "V1";
db.Views.InsertOnSubmit(v);
db.SubmitChanges();
var vl = new ViewLayout();
vl.ViewLayoutID = Guid.NewGuid();
vl.ViewID = v.ViewID;
vl.Name = "VL1";
db.ViewLayouts.InsertOnSubmit(vl);
db.SubmitChanges();
}
scope.Complete();
}
Since the transaction is not committed yet, that insert fails because the
result of the first insert is not visible yet.
This is wat dbmonitor is showing:
7/09/2010 17:21:42 n/a dotConnect for Oracle monitoring is started Complete
7/09/2010 17:21:42 0,016 Creating pool manager Complete
7/09/2010 17:21:42 0,000 Creating pool with connections string: "User Id=x;Password=y;Server=voracle01;Direct=True;Sid=WICTEST;Persist Security Info=True;" Complete
7/09/2010 17:21:42 0,000 Creating object Complete
7/09/2010 17:21:42 0,594 Open connection: "User Id=x;Password=y;Server=voracle01;Direct=True;Sid=WICTEST;Persist Security Info=True;" Complete
7/09/2010 17:21:42 0,531 Connect: "User Id=x;Password=y;Server=voracle01;Direct=True;Sid=WICTEST;Persist Security Info=True;" Complete
7/09/2010 17:21:43 0,000 Creating object Complete
7/09/2010 17:21:43 0,000 Prepare: INSERT INTO SRG.KPD_VIEW (VIEWID, NAME) VALUES (:p1, :p2) Complete
7/09/2010 17:21:43 0,031 Execute: INSERT INTO SRG.KPD_VIEW (VIEWID, NAME) VALUES (:p1, :p2) Complete
7/09/2010 17:21:43 0,281 Open connection: "User Id=x;Password=y;Server=voracle01;Direct=True;Sid=WICTEST;Persist Security Info=True;" Complete
7/09/2010 17:21:43 0,265 Connect: "User Id=x;Password=y;Server=voracle01;Direct=True;Sid=WICTEST;Persist Security Info=True;" Complete
7/09/2010 17:21:43 0,000 Creating object Complete
7/09/2010 17:21:43 0,000 Prepare: INSERT INTO SRG.KPD_VIEWLAYOUT (VIEWLAYOUTID, VIEWID, DESCRIPTION, XML) VALUES (:p1, :p2, :p3, :p4) Complete
7/09/2010 17:21:43 58,609 Execute: INSERT INTO SRG.KPD_VIEWLAYOUT (VIEWLAYOUTID, VIEWID, DESCRIPTION, XML) VALUES (:p1, :p2, :p3, :p4) Complete
7/09/2010 17:22:42 0,000 Connection is returned to pool. Pool has 2 connection(s). Error
7/09/2010 17:22:46 0,016 Close connection Complete
7/09/2010 17:22:46 0,016 Connection is returned to pool. Pool has 2 connection(s). Complete
I wasn't expecting a second connection to be used.
I have to a that I'm using direct mode.
Can you please help me with this?
Thanks,
Marc