petrus (12) [Avatar] Offline
#1
You should provide a real conflict resolution sample. I understand how to roll back a transaction if you get a conflict. But how can I really fix the data and resubmit it in order to get it through to the database.

If the DatabaseValue is no longer equal to the OriginalValue, I cannot put the data back into the database, right? So how can I tell LINQ that the OriginalValue should be "upgraded" to the current DatabaseValue, so I can try a new call to SubmitChanes? Is this possible at all?
steve.eichert (22) [Avatar] Offline
#2
Re: Conflict resolution
Pierre,

Thanks for the recommendation. I can't speak to whether or not we were able to squeeze a example as you suggested into the LINQ to SQL chapters, however, I'll drop Jim a note about it (Jim wrote the LINQ to SQL chapters).

Best Regards,
Steve
jwooley (123) [Avatar] Offline
#3
Re: Conflict resolution
We discuss this in chapter 8. With this you can set the context.ChangeConflicts.ResolveAll using the appropriate RefreshMode. In addition, you can use the code in listing 6.8 to display the details of the conflict to the user. With this information, you should be able to create a UI feature that will let the user pick which option they want to retain for each record. You would then manually set the values that you want to persist and then re-submit them forcing your changes over any concurrency conflicts that may still arise.
petrus (12) [Avatar] Offline
#4
Re: Conflict resolution
Hi Jim,

Thank you for the reply. The UI part is not bothering me in this case. It is the way you use the RefreshMode to get away with the conflicts.

Say that you have 10 modifications and one produces a conflict. As I don't want any of them to be persisted in case of a conflict, so I'll automatically roll back the transaction in which I attempted my modification. So currently, no row has been written back to the database and I know which one is in conflict and I can decide what to do (i.e. let the user decide what to do or fix the data and resubmit).

Then, I'll have to resubmit my 10 modified rows. What I do not get is this: how does the system know that the previously conflicted row has been fixed and should be considered as "overwrite unless the data in the database changed again since the conflict resolution" and handle the 9 other rows as "update" and still handle further conflicts which may occur because of new changes in the database?

Is this possible at all? Or do I have to forget my 10 modified rows; query them anew from the database, apply changes locally and resubmit everything?

I hope I am phrasing my questions in a sufficiently clear way.

Thank you for your time.

Pierre