3

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.

g.foley
  • 2,152
  • 3
  • 19
  • 27

1 Answers1

1

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.

Community
  • 1
  • 1
Chris Moutray
  • 18,029
  • 7
  • 45
  • 66
  • Beat me too it mouters! Here's another answer with some code http://stackoverflow.com/questions/4921899/simple-aggregate-root-and-repository-question/4931457#4931457 – David Masters Jul 25 '11 at 21:37