Azure SaveChanges 与 SaveChangesWithRetries
查看人们编写的示例,我发现很多人使用 SaveChanges 而不是使用 SaveChangesWithRetries。我认为 SaveChangesWithRetries 是最好的选择,那么仅使用 SaveChanges 有什么优势吗?另外,如果我执行 SaveChangesWithRetries,是否还需要配置其他任何内容,或者我应该使用默认值?
_LogEntryServiceContext.MergeOption = MergeOption.PreserveChanges; _LogEntryServiceContext.AttachTo("LogEntry", 要删除的项目,“*”); _LogEntryServiceContext.DeleteObject(itemToDelete); _LogEntryServiceContext.SaveChanges(); _LogEntryServiceContext.Detach(itemToDelete);
谢谢,
真理子
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 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,我总是使用 SaveChangesWithRetries - 但我仍然需要添加自己的错误处理。
无论您选择哪种方法,这两种方法都要求您处理非常罕见的问题:
好消息是(根据我的经验)失败很少见。然而,这对于“事务关键”类型的数据来说可不是什么好消息!
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:
The good news is that failures are (in my experience) rare. This isn't good news for "transaction critical" type data, however!