Design patterns 如何为聚合设计领域驱动的设计应用程序服务?

Design patterns 如何为聚合设计领域驱动的设计应用程序服务?,design-patterns,architecture,domain-driven-design,Design Patterns,Architecture,Domain Driven Design,我是域驱动设计的新手,所以我想问一下如何使用聚合根的应用程序服务 public class Product: AggreagateRoot{ publis int Id {get; set;} publis string Name {get; set;} public ICollection<Comment> Comments {get; set;} public ICollection<Types> Types {get; set;}

我是域驱动设计的新手,所以我想问一下如何使用聚合根的应用程序服务

public class Product: AggreagateRoot{
    publis int Id {get; set;}
    publis string Name {get; set;}

    public ICollection<Comment> Comments {get; set;}
    public ICollection<Types> Types {get; set;}
}
我有一个聚合根

public class Product: AggreagateRoot{
    publis int Id {get; set;}
    publis string Name {get; set;}

    public ICollection<Comment> Comments {get; set;}
    public ICollection<Types> Types {get; set;}
}
我是否应该像下面这样在ProductService中添加创建和更新注释和类型的方法

public class ProductService {

    public Product Create(ProductCommand command){
        .....
        ...
    }

    public Product Update(ProductCommand command){
        .....
        ...
    }

    public Comment Create(CommantCommand command){
        var product = _context.Product.Find(command.ProductId);

        product.Comments.add(new Comment(command.message));

        _context.SaveChanges();
        .....
        ...
    }

    public Comment Update(CommantCommand command){
        var comment = _context.Comments.Find(command.Id);

        comment.message = command.message;

        _context.SaveChanges();
        .....
        ...
    }       
}
或者我应该为注释和类型创建单独的服务吗

public class Product: AggreagateRoot{
    public int Id {get; set;}
    public string Name {get; set;}

    public ICollection<Comment> Comments {get; set;}
    public ICollection<Types> Types {get; set;}
}
我应该为注释和类型创建单独的服务吗

public class Product: AggreagateRoot{
    public int Id {get; set;}
    public string Name {get; set;}

    public ICollection<Comment> Comments {get; set;}
    public ICollection<Types> Types {get; set;}
}
应用程序组件应该只与聚合根通信。这就是有根的部分意义。因此,如果我们假设注释和类型属于一个聚合,那么不,不应该为它们提供单独的服务

如果多个产品共享同一类型,那么将该类型作为自己的聚合可能是有意义的