I've run across an issue in trying to implement concurrency conflict handling in my Silverlight application (DevForce 5.2.4.2). I have modeled my concurrency handler after the concurrency handler in the "HandlingConcurrencyConflicts" WinForms sample project in the Learning Resources.
I am trying to verify the case where the local user is attempting to update a record that has already been deleted by another user. I have opened the database in SQL Server management studio and I have also started my application at the same time. I delete a record from the table and then in my application I make an update to the record and then attempt to save. I get a concurrency conflict as expected but I find that because the entity has an original value I end up falling into the block of code that handles the case where the local user and remote user both made changes to the record instead of falling into the block of code that handles the scenario I'm trying to verify.
For further clarification, my code is essentially the same as that in the "ResolveMyConflicts" routine in the "ConcurrencyHandler" class in the Learning Resources sample.
Looking at that routine, the first thing that is done is RefetchEntity is called with the MergeStrategy set to "PreserveChangesUpdateOriginal". If you read the documentation on this MergeStrategy it states:
"The refetch replaces the cached entity's original version with the values from the current data source entity but it preserves the cached entity's current version values thus retaining the pending changes"
I can see where that makes sense for the case where two users make changes to the same record but how would this work in the case where the record doesn't exist in the data source because it was deleted?
What happens to the original version values of the cached entity? Is there a flag I should be looking at that tells me the record in the data source was not found and so the original version values of the cached entity were not replaced from the data source so that I can then move into the correct block of code to handle this particular type of concurrency conflict?
I tried switching to the "PreserveChangesUnlessOriginalObsolete" merge strategy but that takes me into the block of code that handles the case where the local user tries to delete a record that was modified by another user.
Could someone explain to me how this scenario works and where I am going wrong and the Learning Resource sample seems to be going wrong as well?