我試着去saveChanges的saveError方法中測試下面的代碼。我試過的只是在瀏覽器的不同選項卡中打開同一個實體並刪除兩者。第二次刪除實際上給了我System.Exception在innerexception中有併發異常的服務器。但是細節prop是不確定的。
var reason = error.message;
var detail = error.detail;
if (error.entityErrors) {
reason = this.handleSaveValidationError(error);
} else if (detail && detail.ExceptionType &&
detail.ExceptionType.indexOf('OptimisticConcurrencyException') !== -1) {
// Concurrency error
reason =
"Another user, perhaps the server, " +
"may have deleted one or all of the todos." +
" You may have to restart the app.";
} else {
reason = "Failed to save changes: " + reason +
" You may have to restart the app.";
}
這是我從服務器獲取的SaveChanges後的反應
![enter image description here](https://i.stack.imgur.com/gEmv5.jpg)