views:

45

answers:

1

I am new to domain driven development & have a simple question. If a service needs 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 ?

Thanks & regards

+1  A: 

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.

JontyMC