views:

28

answers:

1

I am using linq to sql as ORM for my asp.net mvc website.

I dont know how will linq to sql behave in the following situation.

Suppose one of the action from a active session, modifies a row of a table and before saving the changes to the database, I mean before calling _db.SubmitChanges() another action from some other session tries to access the same row. I am sure linq to sql will not allow me to get that row, because that's not the updated data.

So my question is, what will happen in such scenario? How to deal with such scenario?

I have never received an error yet, because my website is still in development stage, and there are not many sessions at any given time.

+1  A: 

You will be able to access the original row, up until SubmitChanges() is called, at which point the row will be locked briefly before becoming available again.

you can read about optimistic concurrency control and linq here

Paul Creasey