ConflictDetection

Nov 4, 2007 at 5:42 PM
Edited Nov 5, 2007 at 9:26 AM
Hi

I really want to use the repository factory in a real project but here is the situation that i am facing:
It's a client - server scenario. I have a Users table with ID, FirstName and LastName columns. The problem is that when one client app retrieves a user with id=2 and changes the firstname and then update the db, but in the same time some other client app changes and updates the firstname of the same user with id=2 before the first client app makes his update, then the first client has no idea that the firstname is changed by someone. When this will be fixed? (of course the ConflictDetection should be configurable enabled or disabled)
To make my problem even more clear to understand please see some solution I have in mind :)

Keep track of the original properties firstname and lastname and when updating return -1 or some other code to let the app know what has happened

create proc updateuser
(
id,
original_firstname,
original_lastname
firstname,
lastname
)
as
begin

update users
set ....
where ....

if(@@rowcount = 0)
return -1

end
Developer
Nov 5, 2007 at 11:45 AM
I believe the current version of the Repository Factory provides optimistic concurrency using a Timestamp Column. Therefore, if you have a Timestamp column in the table it will use that column during updates to determine if any data in the row has changed while doing an update. If the data has changed, it will not update the data but instead throw an exception, letting you know that the data has been changed by another prior to doing the update.

Regards,

Dave

______________________________

David Hayden
Microsoft MVP C#