Search code examples
linq-to-sqllocking

C# Linq to SQL: will multiple reads/writes cause prolonged locking?


Suppose

  • I create a Linq to SQL DataContext
  • I read one record using this DataContext
  • I spend ten seconds to think
  • I change the record and submit the changes using this DataContext.

Are the table locked during these ten seconds?


Solution

  • No, they would not be locked when you 'spend ten seconds to think', otherwise this would be sort of checking out rows/tables. Of course, this means that some other process could also read and write changes in those ten seconds, which could lead to concurrency issues for you.