What would I need to do in my dataset C# client for handling optimistic concurrency?
This article does not go into many details except from use a timestamp
What would I need to do in my dataset C# client for handling optimistic concurrency?
This article does not go into many details except from use a timestamp
Assuming your handling this all yourself.
If the timestamp you retrieved from the DB originally is less then the timestamp currently persisted on the object, then someone else has persisted data and you should not allow the current user to persist, or at least prompt them that they might be overwriting changes.
Without a more detailed question, I don't really know what else to say.
What would I need to do in my dataset C# client for handling optimistic concurrency?
Nothing. it is not the jkob of a data set to handle this - the data set is an offline cache of data. It is the job of whatever you use to write the changes out to the database to handle optimisstic concurrency based on the information given in the dataset.
Datasets do not deal with database interaction at all.
That's not really correct, the article just mentions timestamps (the use case in the first half or the article), and alternatively provides more details on the second optimistic lock implementation -
The magic is performed by the following statement:
So you'd just listen to
RowUpdated
event, and ifRecordsAffected
is zero then something bad happened.Timestamp-based implementation is pretty obvious as well. You'll have a datetime along with your dataset:
For updating you'll have two ways - explicit, when you check timestamps even before attempting to save anything:
Or implicit, like the second way described in the article - try update using timestamp as a condition:
and if zero rows are updated then you'll know about concurrency exception and report correspondingly.