Searching for a Child across Aggregate Roots

前端 未结 3 721
自闭症患者
自闭症患者 2021-01-14 17:07

The repository pattern suggest that you can only pull aggregate roots. But how would you retrieve a single child using only it\'s uniqiue identity(Child.ID) if you do not kn

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-14 17:55

    If you require the child for display/reporting/viewing/reporting then a simple query layer will do.

    If you are manipulating the child in any way then it has a consistency boundary and it sounds an awful lot like an aggregate.

    Try not to query your domain objects. Another simple rule of thumb is not not include an aggregate reference in another aggregate but to rather use just the referenced aggregate's Id or even a value object representing the relationship.

提交回复
热议问题