Concurrency in N tiers

R

Rodolfo

Hi, I'm creating the arquitecture of a N tiers application, at the moment I
decided to use classes to inherit from Dataset in order to represent the
Data Entities.

However I hit the concurrency problem and I'm not sure how to prevent it
(timestamps, sp, etc.) Can anyone recomend me a good strategy to manage
concurrency?

TIA
 
W

W.G. Ryan eMVP

If you use DataSets than you can handle it directly with the dataadapter.
LIke you mention, TimeStamps are another great way to handle them
 
S

Sahil Malik

Rodolfo,

First you need to decide on the concurrency model you choose.

1. Timestamps?
2. Check for all values.
3. Check for values you are updating?
4. Pessimistic locking (last choice).

Each of the above can be supported by the dataset natively. Timestamps will
let require you to query for the timestamp before data is sent to the UI
layer. #2 and #3 can be checked for by using original values of the
particular columns you are planning to update.

You can also use the above along with any one of the 4 (5 in 2.0/sql2k5)
isolation levels on transactions specific to the exact behavior you need.

In a good architecture though, all this should be abstracted out in the data
layer.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
R

Rodolfo

It seems that Timestamps are the less time consuming technique rigth?, I
guess the options 2 and 3 applied to an big table (in terms of columns) can
be very tedious. Can I implemente pessimistic locking with DataSets?, I
beleave I saw some article that it said that you can't

TIA
 
G

Guest

If you are using DataSets and DataAdapter.Update(), it is easier to attempt
update and catch concurrency issues and show the user. IT will catch changes
that trigger concurrency problems.

You can introduce a timestamp into the mix, if you desire, but it is of more
value if you are creating your own concurrency method rather than relying on
what Microsoft has to offer.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
S

Sahil Malik

Rodolfo,

If timestamps were the best way to do it, then other techniques wouldn't
exist. Oracle has an equivalent rowid (I think), but keeping the future in
mind, I like option#3 the best.

You could implement pessimistic locking through datasets, but you'll have to
try very hard to do it :). Either way, it's not the effort, and I don't see
any good reason for an OLTP application to implement pessimistic locking.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top