使用领域驱动设计时如何处理实体的更新/修改
我们目前正在尝试在基于 .NET 的应用程序(ASP.NET、WCF、Castle Windsor、NHibernate 堆栈)中应用域驱动设计的原则。
问题是在表级别,我们已由 (string) 更新,更新于 (日期时间)的订单。当订单被批准后,我们需要获取更新者,更新者反映批准者姓名和他批准的日期/时间。
你们在应用层做了如下的事情吗?请指教
订单 = orderRepository.Find(orderId) order.businessLogicCall1()
order.businessLogicCall2()
order.updatedBy(用户名)
orderRepository.Save(order)
order.updatedBy() 调用还会更新内部字段 UpdatedOn 以获取执行更新时的日期/时间。这由 Nhibernate 发布到表格上
We are currently attempting to apply the principles of Domain Driven Design in our .NET based application (ASP.NET, WCF, Castle Windsor, NHibernate stack)
The question is at the table level, we have updated by (string), updated on (datetime) for Order. When the order is approved, we need to get the updated by, updated on reflect the approver name and the date/time when he approved.
Do you guys do something as below in the Application Layer? Please advise
order = orderRepository.Find(orderId)
order.businessLogicCall1()
order.businessLogicCall2()
order.updatedBy(userName)
orderRepository.Save(order)
Where the order.updatedBy() call also updates the internal field updatedOn for date/time when the update was performed. This gets posted onto the table by Nhibernate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不 order.Approve(anApprover,approvalDate) ,其中 anApprover 是批准它的人?如何在数据库中表示它取决于您。
与此正交的是持久性机制,用于保存执行操作的人员(可能是最终用户)以及每个受影响的实体。这种存储的商业意义较小。
Why not order.Approve(anApprover, approvalDate) where anApprover is the one that approved it? How that gets represented in the DB is up to you.
Orthogonal to that are the persistence mechanisms that save who performed the action (could be an enduser) along with each affected entity. This kind of storage has less business meaning.