I have multiple silverlight applications bolted within an asp solution, multiple users may be using the same application on the same set of data at any one time. The silverlight applications are designed such that they pull data from the database, work on it locally, and write it back once they user is happy with their modifications. The problem with this however, is that if two users are using the same application on the same database, they are going to overwrite each others changes.
There isnt going to be a huge number of users using the same database at any one time, as there are numerous databases, and it isnt essential that more than one user should be working on the same set of data at any one time. My idea is to lock each table for a single user to have exclusive access to read/write to the server, denying any other user access to even read from the locked tables in question.
How would i go about applying the table locks and releasing them? I know it can be done on a per statement basis, but I need the user to have totally exclusive rights to this data. A problem that I can forsee is releasing the lock, there would need to be some kind of timeout, so the table isnt permanently locked for the one user.
I wouldn’t even begin to attempt this, as you’ll have horrible concurrency problems with more than 1 user – including 1 user who uses more than one window, or returns after a crash on their system, etc.
A simple way to deal with this would be to have a timestamp or change count, and if the timestamp or change count has changed since the data was obtained, then warn the user they are going to over-write someone else’s work. From that starting point you can go further and let them pick and choose changes, manually copy in changes from the other person’s, compare changes, etc.