据我了解,绑定上下文可以具有模块,模块可以具有许多聚合根,聚合根可以具有实体。为了保持持久性,每个聚合根都应该有一个存储库。
As I understand, the Bounded Context can have modules, the modules can have many aggregate roots, the aggregate root can have entities. For the persistence, each aggregate root should have a repository.
由于大型项目中有多个聚合根,因此可以使用通用存储库 strong>,一种仅准备就绪,另一种仅更新?或应该为每个聚合根具有单独的存储库,以提供更好的控制。
With the numerous aggregate roots in a large project, is it okay to use a Generic Repository, one for ready only and one for update? Or should have separate repository for each aggregate root which can provide better control.
推荐答案在大型复杂项目中,我不会建议使用通用存储库,因为除了基本的 GetById(), GetAll()外,还有很多其他特殊情况...操作。
In a large complex project, I wouldn't recommend using a generic repository since there will most likely be many specific cases beyond your basic GetById(), GetAll()... operations.
Greg Young撰写了一篇有关通用存储库的精彩文章: codebetter/gregyoung/2009/01/16/ddd-the-generic-repository/
Greg Young has a great article on generic repositories : codebetter/gregyoung/2009/01/16/ddd-the-generic-repository/
可以使用通用存储库,一个仅用于准备就绪,一个用于更新吗?
is it okay to use a Generic Repository, one for ready only and one for update?
存储库通常不处理对实体的保存更新,即,它们没有 Update(EntityType实体)方法。通常由您的ORM的变更跟踪器/工作单元实施来解决。但是,如果您要查找将读写与读写分开的体系结构,则绝对应该查看 CQRS 。
Repositories generally don't handle saving updates to your entities, i.e. they don't have an Update(EntityType entity) method. This is usually taken care of by your ORM's change tracker/Unit of Work implementation. However, if you're looking for an architecture that separates reads from writes, you should definitely have a look at CQRS.
更多推荐
总根的通用Vs个人存储库
发布评论