Domain queries in CQRS

后端 未结 4 845
悲&欢浪女
悲&欢浪女 2020-12-12 14:03

We are trying out CQRS. We have a validation situation where a CustomerService (domain service) needs to know whether or not a Customer exists. Customers are unique by their

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 14:31

    This post by Udi Dahan http://www.udidahan.com/2009/12/09/clarified-cqrs/ contains the following paragraph:

    "Also, we shouldn’t need to access the query store to process commands – any state that is needed should be managed by the autonomous component – that’s part of the meaning of autonomy."

    I belive Udi suggested simply adding a unique constraint to the database.

    But if you don't feel like doing that, based on the statement above, I would suggest just adding the "ByEmail" method to the repository and be done with it - but then again Udi would probably have a better suggestion..

提交回复
热议问题