This is a migrated thread and some comments may be shown as answers.

i want to lock row when i work on it

4 Answers 47 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Omar
Top achievements
Rank 1
Omar asked on 27 Apr 2014, 11:11 AM
i want to lock row and no one can read it before i make unlock
how can i do this??

4 Answers, 1 is accepted

Sort by
0
Omar
Top achievements
Rank 1
answered on 28 Apr 2014, 05:28 AM
any help please??
0
Doroteya
Telerik team
answered on 28 Apr 2014, 10:35 AM
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.
 
0
Omar
Top achievements
Rank 1
answered on 28 Apr 2014, 12:05 PM
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);



0
Ady
Telerik team
answered on 30 Apr 2014, 02:57 PM
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.
 
Tags
Development (API, general questions)
Asked by
Omar
Top achievements
Rank 1
Answers by
Omar
Top achievements
Rank 1
Doroteya
Telerik team
Ady
Telerik team
Share this question
or