3

I am using Entity framework 3.5

I need to edit a database row, and I want to ensure that no other process edits this row once I start editing it.

How do I achieve this in Entity Framework 3.5?

I am looking to lock a specific row, not an entire table.

2 Answers 2

2

This can be achieved by implementing pessimistic concurrency.

Have a look at this tutorial to learn more about concurrency in EF. There are also some tutorials on the same website about how to implement different methods for handling concurrency.

Hope this helps!

Sign up to request clarification or add additional context in comments.

3 Comments

I think Its by default lock the whole table?
I think so to, so one would have to handle locks on individual rows specially.
How do I lock an individual row? I would not want to lock the whole table.
1

You can use Scope like this:

var transactionOptions = new TransactionOptions { IsolationLevel = IsolationLevel.Serializable, Timeout = TimeSpan.MaxValue }; using (var scope = new TransactionScope( TransactionScopeOption.Required, transactionOptions)) { // Your code } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.