5 ms·
I usually create "Service" classes in the domain layer, which use Repositories. These repositories are a wrapper for the DbContext to allow unit testing. Where
by kenniskrag 5y ago
I usually create "Service" classes in the domain layer, which use Repositories. These repositories are a wrapper for the DbContext to allow unit testing. Where do you put your domain logic? Do you have a domain model or is your persistence model your domain model?
- telchar 5y agoCan you expand on how those repositories are written and how you use them for unit testing?
- brainwipe 5y agoDomain model is the peristence model. Splitting them apart is often known as an anemic domain model (in Domain Driven Design). All the domain logic is on the entity. So our command handlers (akin to your service methods) look like: 1. Load entity 2. Call method on entity, passing in data 3. Save entity 4. Raise events So we only unit test 2. because that's the domain code. Loading entities from the dbContext is someone else's code. So is saving. So is raising events. If your entity class gets big, split out the functionality into other classes so that you end up with a fair portion of bodyless methods. Hope this is making sense!