我应该如何构建我的存储库类?
我是 DDD 新手。在我的小型项目中,我有一个如下所示的结构(与实际名称不同):
- EntryClassificationGroup
- EntryClassification
- Entry
- EntryType
我是否应该为所有这 4 个实体只有一个存储库类,因为它们都是相关的?或者我应该为每一个都有单独的存储库?
I am new to DDD. In my mini-project, I have a structure that looks like this (different from the actual names):
- EntryClassificationGroup
- EntryClassification
- Entry
- EntryType
Should I have just one repository class for all these 4 entities, since they are all related? Or should I have individual repositories for each one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您是否可以独立于您的条目添加/删除/更新EntryClassification或EntryClassificationGroup,并且它们是否可以独立于您的条目存在?如果是这样,最好有一个单独的存储库。
您可能担心在此处查询存储库中的数据,但查询对象模式允许您通过Entry 存储库中的不同字段,例如 EntryType。所以你可以克服这个问题。
The question is can you add/delete/update EntryClassification or EntryClassificationGroup independently from your Entry and is it possible for them to exisit independently form your entries? If so it might be good idea have separate repository for it.
You might be concerned about querying data from your repositories here but Query object pattern allows you to query by different fields in the repository for Entry, let say by EntryType. So you may overcome this issue.