DDD, how to maintain relationships between objects?

I am new to the DDD world, I want to apply it to our DDD application with ADO.NET. In DDD there are objects, an aggregated root, an object of value. I have two objects, for example a blog, that can belong to several categories. In fact, I think the blog post and category should all be combined. The blog post and category all have a repository, PostRepository and CategoryRepository, but now I'm confused about how to implement a 1: lot relationship between post and category objects.

In the DAO template, there is a DAO corresponding to the table, we can save the connection in the DAO class. But in DDD there is the concept of Unit of Work, it can ensure the aggregate root to work correctly, for example, there should be some repositories about the objects of the aggregate root. but for a relationship, I don’t think it should have a repository, this is not the essence here.

Is there a best practice to address these scenarios? or should I add two procedures (add message, add category) and call them when I save the message?

+4
source share
1 answer

You must have one repository for each placeholder.

, , . . , ( ). , - ( ).

"" "", . , Post. , " ", , Post. , , , id ( ) Post.

, . DDD. . , 100% , .

+2

Source: https://habr.com/ru/post/1664250/


All Articles