问题
UPDATE: Here is a plnkr to illustrate the problem http://plnkr.co/edit/bwQL3o?p=preview
Scenario in offline mode
You create an entity and store it in the localstorage
Breeze generates a tempKey: EmployeeId: -1 and populates a tempKeys array with the EmployeeId: -1. Every thing is all good and great.
Later on, (the application was terminated the device was turned off...) you import the stored data and create a new entity.
So Breeze loads the stored data sees the TempKeys of EmployeeId: -1 and generates a new EmployeeId: -2 Every thing is still good and great.
The problem
- When you store this new data set in the localstorage the tempKeys array only contains the EmployeeId: -2 entry.
- Later on, when you import the stored data and try to create a new Employee you get an Error:
A MergeStrategy of 'Disallowed' does not allow you to attach an entity when an entity with the same key is already attached: Employee:#Context--1
The question
Why is Breeze not keeping track of the current TempKeys? Is this a Bug? How do we fix this Scenario ? Any help would be greatly appreciated.
回答1:
Ok, this was a bug and has now been fixed in the breeze.js repo on GitHub. This fix will also go out on the next full release of Breeze.js ( probably sometime next week). ... and thanks for finding this and providing the plunkr.
来源:https://stackoverflow.com/questions/24276588/breeze-offline-mode-issues