Home > Uncategorized > LinqToSQL and UpdateChecks

LinqToSQL and UpdateChecks

By default, LinqToSQL uses pessimistic concurrency when saving the changes to the tables. what this means is that it will check all fields when doing any updates or deletes, this usually goes against what we normally do with normal sql where we just update based on the primary key.

Additionally, this increases the load on the db server as well, since all updates and delete statements needs to go thru this check.

What’s good about this is that it ensures the data is the same as what you had before the update so that it is sure that it is updating the correct data.

So now, what if you do not want this behavior or want to settle for optimistic concurrency? By default each column in all the tables will have the updatecheck property set to always.

You can change it to Never for L2S to not check this column when doing updates/delete.

Alternatively there is a “When changed” which will check only when the field is changed.

Exactly which mode you prefer depends on your business model. But bear in mind that UpdateCheck=Always will increase the load on the db server quite easily especially during high update/delete loads

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: