|
I have a dashboard type interface with windows that have views that have column settings. I need to auto save the UI settings while allowing the UI to remain active. Each client / user / login has its own settings
so there are no concurrency issues on the server.
The problem is that entities are set to read-only when SubmitChanges is pending. So, if a user drags a window, resizes a column etc. an exception occurs because the entity / property is locked as read-only during
the submit process.
I have been looking at the partial change capabilities of EntityGraph and I see that recent features seem to provide most of what I need. However, the learning curve is pretty steep and I do not want to write code
duplicating functionality the classes already contain. I am hoping for some guidance.
In my case, I do not necessarily need a partial change. A full submit is fine because my context only contains the entities I want to submit add/changes/deletes for.
I would like to implement a client wins strategy like so:
1. Save all changes to the server without requiring concurrency check against the original. It would be nice if I can get the server to optimize the changes by simple UPDATE without any re-fetch/checks (last wins).
2. On return to the client:
A. No Errors =
i. Update calculated fields (Identity column is the primary key on all tables).
ii. Keep any deletes/ changes / states that occurred on the client during the submit operation. These will be submitted during the next auto-save.
B. Error =
i. Original context should have all old adds/changes/deletes and any new ones that occurred during the submit operation. The next auto-save will re-submit.
I think that clearing the original context’s states before submit will allow the concurrent changes to be tracked. Perhaps there is a better way?
I have read about the Partial Change methods, Synchronize, AcceptChanges etc. But, I am not sure about the path I should take.
First of all, I need to get the deletes submitted. Is there a simple way to move them to the temp context?
Secondly, the Synchronize looks like it will overwrite any changes that happened while the submit operation was in progress. Should I make a copy of the orig, apply the returned temp context changes and then apply
the changes from the copy (so the concurrent changes take precedence)???
Hopefully, the code I need is simpler than I think?
Any and all suggestions will be appreciated.
TIA
|