开发者

DDD - Returning entity in response to a service operation

I am new to domain driven development & have a simple question. If a service 开发者_如何学Goneeds to generate some entity as a response to an operation then how should it be done? One of the ways is to inject entity factory in the service instance. Is there any other better solution for the same ?


Factories are usually for complex entity creation. You could simply new up the object. Its not clear whether you mean creating or retrieving. If you are retrieving, you can inject a repository and use that. Also, services typically return DTOs, not the actual entities themselves. Outside of the domain should not know about entities.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜