领域驱动设计
我正在寻求有关 DDD 的以下两点的澄清。
1.领域实体可以调用存储库吗?
2.领域服务可以调用存储库吗?
谢谢
编辑
找到了一套文档,详细介绍了 DDD 层,这就是它所说的;
此外,虽然通常存储库仅在应用程序层使用,但也可以例外,并根据需要从域服务调用存储库进行查询。但应该尽可能避免这种情况,以实现我们发展的同质化。
I'm looking for clarification on the following 2 points with regards to DDD.
1.Can a domain entity call a repository?
2.Can a domain service call a repository?
Thanks
Edit
Found a suite of documents that detailed the DDD layers in lots of detail and this is what it said;
Additionally, and although as a rule Repositories are only used from the Application layer, it is also possible to make exceptions, and make queries invoking Repositories from the Domain services as necessary. But this should be avoided as much as possible in order to achieve homogeneity in our developments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不会设计一个域实体来引用存储库。 “存储库”很少是域的一部分,并且会在域模型中引入技术问题。我发现最适合应用程序服务层的存储库。
I wouldn't design a domain entity to reference a repository. A "repository" is rarely a part of the domain and would introduce a technical concern into your domain model. I've found repositories to fit best at the application services layer.
我不知道有这么严格的规则。 任何事情都可以做。
但我是这样做的。我不知道它是否符合 DDD:
I'm not aware of such hard and fast rules. Anything can be done.
But here's how I do it. I don't know if it qualifies as DDD: