Search code examples
linq-to-sqlsql-server-2008-express

Linq2SQL locking object in multithreaded environment?


I have an windows service application where I have an object that is processed during rather long time. During the process time the user can interact with the object from a GUI and calling WCF-services on the service. Sometimes, haven't been able reproduce the problem, it seems that the user updates a childobject on my main object it causes the processing to not find the object in the repository. Can this really happen? Would wrapping the calls to the repository in TransactionsScope help?

ProcessThread: Works on the object

WCF-service: updates some child objects in a property on the object

ProcessThread: can't find object

Any clues? I'm creating a new DataContext all the time so it's not shared in any way


Solution

  • It seems that it was a concurrency problem with "Missing and Double Reads Caused by Row Updates" as described in http://technet.microsoft.com/en-us/library/ms190805.aspx