Page 1 of 1

Pessimistic locking with RepeatableRead ?

Posted: Thu 25 Aug 2011 09:28
by mer
I tried the following, to enforce pessimistic locking:

Code: Select all

List orderLineIds = new List { 1441932, 1441933, 1441934, 1441935 };
using (TgwWcsDataContext dataContext = DataContextFactory.GetDataContext(this, true))  {
  using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required,
          new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.RepeatableRead}))
    {
       IQueryable existingOrderLines = from ol in dataContext.Orderlines
                                                               where orderLineIds.Contains(ol.OrderlineId)
                                                               select ol;
       foreach (Orderline existingOrderLine in existingOrderLines.ToList())
                    {
                        existingOrderLine.ChangedOn = DateTime.Now;
                        dataContext.SubmitChanges();
                    }
      ts.Complete();
      }
   }
I expectet, that this generates a select for update in oracle, but the "for update"-Clause is missing. What is going wrong ?

I am using Devart.Data.Oracle,Version=5.70.170.0.

Posted: Tue 30 Aug 2011 14:28
by StanislavK
LinqConnect does not support pessimistic concurrency for Oracle. We will consider possible ways of supporting it, and will post here about the results.

At the moment, you can, e.g., explicitly lock rows with a 'select for update' statement called via the ExecuteQuery method.