i want to lock row when i work on it

5 posts, 0 answers
  1. Omar
    Omar avatar
    5 posts
    Member since:
    May 2013

    Posted 27 Apr 2014 Link to this post

    i want to lock row and no one can read it before i make unlock
    how can i do this??
  2. Omar
    Omar avatar
    5 posts
    Member since:
    May 2013

    Posted 28 Apr 2014 in reply to Omar Link to this post

    any help please??
  3. DevCraft banner
  4. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 28 Apr 2014 Link to this post

    Hello Omar,

    Thank you for your interest in Telerik Data Access.

    The result you need can be achieved if a transaction that locks a given row is started. With Telerik Data Access this can be done with a combination between the MakeDirty and FlushChanges methods. In the thread from this link, you can find detailed explanation and an example that demonstrates the implementation.

    I hope this helps. If you need additional information, do not hesitate to get back to us.


    Regards,
    Doroteya
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  5. Omar
    Omar avatar
    5 posts
    Member since:
    May 2013

    Posted 28 Apr 2014 in reply to Doroteya Link to this post

    thank you for your reply i am using old open access
    i dont need to update in row i will select it
    all thing i need
    i want to prevent any body make select on the locked row

    iam using this code but not working

     
    public void LockRead(object target)
    {
        objScope.TransactionProperties.Concurrency = TransactionMode.PESSIMISTIC_EXPLICIT;
        objScope.Transaction.Lock(target, LockMode.READ);
    }

    then call this
    var ftpDataStoreToLock = dp.SelectEntity<FtpDataStore>().Where(s => s.FtpDataStoreID == 4 ).FirstOrDefault();
     
    dp.LockRead(ftpDataStoreToLock);



  6. Ady
    Admin
    Ady avatar
    588 posts

    Posted 30 Apr 2014 Link to this post

    Hi Omar,

    There is no direct API that can exclusively lock a row on SELECT. Even if such a lock is obtained another SELECT can always succeed with a NOLOCK hint.
    As suggested earlier you can execute a dummy update by marking the object dirty ( scope.MakeDIrty) and then calling scope.Transaction.Flush. This will get an exclusive lock on the row which will block other reads (with default isolation level. A 'read uncommitted' select will succeed).

     
    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top
DevCraft banner