One of the things that developers need to think about
in multi-user database systems is how to handle simultaneous updates of the
same data in the database. For example, assume two users retrieve a
product object within an application, and one of the users changes the
ReorderLevel to 0 while the other changes it to 1. If both users then
attempt to save the product back to the database, the developer needs to decide
how to handle the change conflicts.
One approach is to just "let the last writer win"
- which means that the first user's submitted value will be lost without the
end-users realizing it. This is usually considered a poor (and incorrect)
application experience.
Another approach which LINQ to SQL supports is to use an optimistic concurrency model - where LINQ to SQL will
automatically detect if the original values in the database have been updated
by someone else prior to the new values being persisted. LINQ to SQL can
then provide a conflict list of changed values to the developer and enable them
to either reconcile the differences or provide the end-user of the application
with UI to indicate what they want to-do.
I'll cover how to use optimistic concurrency with LINQ to
SQL in a future blog post.