是否有一种设计模式或方法可以从 UI 中删除 Db 上的记录?
当涉及从数据库中存在的用户界面删除记录时,是否有任何常用的方法或一种设计模式或模型?
基本上应该采取以下步骤以及何时采取(例如验证、删除主记录、出现异常时如何处理)
与 REFERENCE 约束冲突
如何处理异常或通知用户失败(如何将 BL 失败信息传输到 UI;通过捕获异常或某些报告对象等)以及或多或少与删除上下文有关的最常见问题。
Is there any commonly referred methodology or a kind of design-pattern or a model when it comes to delete a record from user interface which exists in a database?
Basically what following steps should be taken and when (like validation, deleting the main record, how to handle when there is a
Conflict with the REFERENCE constraint
How to handle exceptions or notifying user on a failure (how to transfer the BL failure info to the UI; by catching exceptions or some report object etc.) and more or less the most common issues regarding to the deletion context.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
删除记录时,您可以执行以下操作:
您的业务层使用什么?您使用什么 API 在代码中检索和存储数据?
When you delete a record, you can do a few things:
What are you using for your business layer, and what API's are you using to retreive and store data in your code?
首先,我认为您需要将数据层与实际的后端数据存储分开。你可以使用 NHibernate 或 Microsoft 的实体框架来使 ORM(对象关系映射)更容易。这样,您在 GUI 中显示的数据就代表了代表数据库中数据的对象。
您可以使用 MS Entreprise Libraries Validation 块进行验证。
还取决于您使用的是 Winforms 还是 WPF。您必须确保某种服务/模型正在处理所有 CRUD 操作而不是 GUI,以便您可以通过单元测试来测试更新位
First things first i think you need to separate your DataLayer from the actual back end data store. you could NHibernate or Microsoft's Entity Framework to make ORM (Object Relational Mapping) easier. So that your data your show in your GUI represents object which represents data in the DB.
you could use MS Entreprise Libraries Validation block to the validation.
Also depends if you are using Winforms or WPF. you have to make sure some sort of Service/Model is handling all the CRUD ops and not the GUI so that you can test the updating bit with unit tests
对于您描述的数据库问题,请考虑采用集中式异常管理策略,以便在数据层中一致地捕获和抛出异常。您应该:
For database issues like you describe, consider a centralized exception management strategy so that exceptions are caught and thrown consistently in you data layer. You should: