使用传统 ado.net 对聚合根进行 CRUD
谁能向我展示使用传统 ado.net 聚合根的简单 CRUD 语句? 提前致谢!
Can anyone show me simple CRUD statements for aggregate root using traditional ado.net?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(这是在假设使用 GUID 或某些非数据库生成的主键的情况下编写的)
此外,许多锅炉代码(例如连接管理等)应该移动到存储库的基类中。
如果 Order 是聚合根,则可能应该将 OrderLineRepo 设为程序集私有,
但是我要强调的是,这实际上是一个简单的幼稚实现,并且如果按照要求执行 DDD,我个人会使用像 nHibernate 这样的 ORM 来实现持久性对于一个经过良好测试的持久层来说,这是不平凡的
此外,这还假设 IsDirty 函数考虑了子项 - 我们还需要一种方法来查看订单是否是新的/编辑的,而不仅仅是脏的
(This is written on the assumption that a GUID or some non-database generated primary key is used)
Also alot of boiler code such as connection management etc... should be moved to a base class for Repository.
If Order is the aggregate root, one possibly should make OrderLineRepo private to the assembly
However I'd stress that this is really a simple naive implementation, and that I'd personally utilize an ORM like nHibernate for my persistence if doing DDD as the requirements for a good well tested persistence layer are non-trivial
Also this assumes that the IsDirty function takes children into account - we would also require a means to see if the order is new/edited, not just dirty