开发者

WCF: Concurrent access to a common database from multiple Web Services

I'm currently developing multiple Web Services that need to access a common database.

I would like to use Entity Framework in order to interact with the DB.

What would be the best course 开发者_开发问答of action in order to avoid possible concurrent operations from occurring ?

For example, I have a Web Service that manages User details in the DB. How can I avoid scenarios such as one Client deletes a User while another tries to update it ?

Furthermore, there's also the possibility of multiple Web Services having to share access to the same tables in the DB, which also brings concurrence problems.

Thanks

Note: I haven't decided yet if the Web Services themselves will be Singletons, but it might be a possibility. I have yet to determine if this will be beneficial...


This does not depend on WebServices or WCF.

When you create a classic Client/Server desktop application you also have concurrency issues to deal with.

What would be the best course of action in order to avoid possible concurrent operations from occurring ?

In general you don't. This would require some complicated and performance-killing locking code.

For example, I have a Web Service that manages User details in the DB. How can I avoid scenarios such as one Client deletes a User while another tries to update it ?

Just let it happen. One of the two will get an error. Your task is to handle that error, and present it to the user. You will have to handle errors anyway (lost connection).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜