Azure SaveChanges vs SaveChangesWithRetries
Looking at examples that people have coded I see a lot of people using SaveChanges and not using SaveChangesWithRetries. I assume SaveChangesWithRetries is the best thing to do so is开发者_如何学C there any advantage in just using SaveChanges? Also if I do SaveChangesWithRetries is there anything else that I need to configure or should I just go with defaults?
_LogEntryServiceContext.MergeOption = MergeOption.PreserveChanges; _LogEntryServiceContext.AttachTo("LogEntry", itemToDelete, "*"); _LogEntryServiceContext.DeleteObject(itemToDelete); _LogEntryServiceContext.SaveChanges(); _LogEntryServiceContext.Detach(itemToDelete);
Thanks,
Mariko
In general I always use SaveChangesWithRetries - but I do also still have to add my own error handling.
Regardless of which you choose, both methods require you to handle very rare issues/problems:
- in the case you are saving multiple changes then you need to work out a strategy for when half the changes fail
- in some rare cases, saves can fail due to connectivity/availability issues
- in some rare cases, saves can appear to fail due to connectivity issues, but may actually have succeeded - and in this case then retries appear to fail.
The good news is that failures are (in my experience) rare. This isn't good news for "transaction critical" type data, however!
精彩评论