I couldn't find a specific answer to my question but how would I develop an AggregateRoot class for the following scenario.

public class Root{

    public int Id {get;set;}
    public IList<Child> Children {get;set;}


public class Child{
    public int Id{get;set; }
    public IList<SubChild> SubChildren{get;set; }

public class SubChild{
    public int Id {get;set;}

How can the root class update the SubChild class following DDD principles?

  • 1
    It's unclear what you're asking here. If your goal is to simply follow the rules, then learn the rules. Otherwise, find a sensible class structure, and work out how the classes are going to communicate with each other. Jan 18 '18 at 1:23

What you want to do violates the Law of the Demeter. Subchildren should be managed by Child only, not Root class.

You might think about this like your Root is an aggregate, Child - is a subaggregate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.