开发者

Dotconnect for Oracle - EF - too many local sessions in Global Transaction

I have to insert 2 records in to one db and around 40 records in to another db in a single transaction. I am using TransactionScope and开发者_JAVA百科 getting this error.

I did read this article but that does not help because there are 2 db's are involved and it is a Distributed Transaction.

http://www.devart.com/blogs/dotconnect/index.php/entity-framework-tips-and-tricks-part-3.html

My code is somewhat like below.

using (var ts  = new TransactionScope()) {
    using (var context = new MyContext()) {
      for (int i = 0; i < 40; i++)
      {
        var order = context.Orders.Where(a => a.name = 'xxx').Single();
        context.ArchiveOrders.Add(order);
      }
    }
}

Even though I am creating the "Context" outside my loop(unlike the example in the link above), the code still fails with the "too many local sessions" error.

Also, I noticed that every query "context.Orders.Where(...)" is enlisted as a new Transaction. I am using Entity Framework and not Linq to Sql. So the above code breaks at 20 iterations.

What are my options now apart from making them 2 independent local transactions and do the transaction handling manually somehow.


We have replied to you here at our forum. The solution is to add context.Connection.Open(); before the loop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜