Where to raise persistence-dependent domain events - service, repository, or UI?

前端 未结 6 1896
暖寄归人
暖寄归人 2021-01-31 09:03

My ASP.NET MVC3 / NHibernate application has a requirement to fire off and handle a variety of events related to my domain objects. For example, an Order object mig

6条回答
  •  不要未来只要你来
    2021-01-31 09:22

    Having domain events works well if you have Commands, sent to your service layer. It then can update entities according to a command, and raise corresponding domain events in a single transaction.

    If you are moving entities themselves between UI and service layer, it becomes very hard (and sometimes even impossible) to determine what domain events have occured, since they are not made explicit, but hidden under state of the entities.

提交回复
热议问题