concept conflict in category .net

appears as: conflicts, conflicts, conflict, conflict
LINQ in Action

This is an excerpt from Manning's book LINQ in Action.

To support the disconnected model, LINQ to SQL offers two alternatives to apply changes. If you’re just adding a row to a table, you can call the InsertOnSubmit[2] method on the appropriate DataContext’s table object. Change tracking is not necessary for new records, only for changing existing ones, thus calling InsertOnSubmit works fine since we don’t need to worry about conflicts with existing records.

When designing systems for a single user, the developer doesn’t need to worry about how changes that one person makes affect other users. In actuality, it is rare for a production system to be used by only one user, as they typically grow and take on lives of their own. As the system grows to support multiple users, we need to take into account the conflicts that arise when two users try to change the same record at the same time. In general, there are two strategies to handle this: pessimistic concurrency, which locks a second user out of changing a record until the first user has released a lock, and optimistic concurrency, which allows two users to make changes. In the case of optimistic concurrency, the application designer needs to decide whether to retain the first user’s values, retain the last update, or somehow merge the values from both users. Each strategy offers different advantages and disadvantages.

8.1.4. Resolving conflicts using transactions

As we were discussing concurrency options, we noted that updating the database with SubmitChanges could update a single record or any number of records (even across multiple tables). If we run into conflicts, we can decide how to handle the conflict. However, we didn’t point out previously that if some effort is not made to roll back changes, any records that were successfully saved prior to the exception will be committed to the database. This could leave the database in an invalid state if some records are saved and others are not.