Reputation: 484
I am trying to design a application using domain driven design, i have a doubt regarding storage of an entity data. First i am creating an entity and applying business rules on the entity. Finally i want to store this data. I am using repository pattern to abstract the database operations. Now where i need to place code related to saving the entity data to database. Is it goes in the entity? or a domain service?
Upvotes: 2
Views: 1310
Reputation: 1718
Persistence related code would go in the infrastructure layer. I usually put this in it's own assembly and inject the specific implementation of my repositories into my application layer.
You definitely do not want any database code in your entities or domain services.
Upvotes: 1