I'm just starting out with DDD and have built a repository pattern using EF code first which so far is working very well. Now say I have an aggregate root call Animal which has an entity called Status.
Now if I need to populate a drop down list with Status objects, or I need to replace the Status object in animal with a new one. How should I access the Status collection. In this case Status is not an aggregate root and only has meaning by association with Animal, it will have an identity though.
Should I either create a new Repository for Status by making it an aggregate root (it just one of many such things so this might get out of hand), or do I allow access the Status collection via the AnimalRepository with something like GetStatusByID or GetAllStatuses?
This same question could equally apply to value objects such as color, breed, sex etc.
This sort of stuff I'd treat as lookup/reference data; I've found this answer useful in the past: Loading a Value object in List or DropdownList, DDD
But basically I'd have a separate repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With