处理 MVVM SL4 中的数据库错误
简单示例:尝试将记录保存到数据库时发生错误。或者作业可能发生超时。
在 MVVM 中,这将发生在我的模型或数据库访问层中。 (优雅地)处理该错误的方法是什么?
谢谢,
斯科特
Quick example: An error occurred when attempting to save a record to a db. Or perhaps a timeout occurred on a job.
In MVVM, that's going to occur in my Model or DB Access layer. What's the method for handling that error (elegantly)?
Thanks,
Scott
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点大问题。
这也很大程度上取决于您的用户需求。
例如:
您是否只需要向用户表明出现了问题?
只需放置一个带有消息的属性,以及一个指示错误状态的属性,并使您的视图相应地更改自身。
您是否需要限制访问,直到可以修复某些问题?
您的虚拟机可以轻松禁用命令,直到您重新启动连接或采取其他措施。
也许如果您心里有一个场景,我可以更具体:)
HTH
Ariel
Kinda of a big question.
Also it is very dependent on your user requirements.
For example:
Do you need just to show the user that something went wrong?
Simply put a property with a message, and a property to indicate a faulted state and have your View change itself accordingly.
Do you need to limit access until you can fix something?
Your VM can easily disable commands until you have re-initiated your connection or some other measure.
Perhaps if you have a scenario in mind, I can be more specific :)
HTH
Ariel