2

I'm designing a blog architecture on asp.net mvc. Lets say i only have 2 entities: post and comment. do i need a controller and a repository for each one? how goes the mechanism for displaying a post with it's comments? do the post controller looks in the posts repository for the post, then asks the comment controller to retrieve all the comments connected to this post, gets them from the comments controller and passes them to the view? or maybe i should write a service which is responsible for querying both repositories and returning the results to the posts controller, which passes them to the view?

4

4 回答 4

1

Perhaps the first thing to note is what features will your blog have and make available for its primary functions :

  • editing
  • subscription
  • comments
  • authenticating users - eg identifying the blog owner and posters.

What other ideas will yourblog have ? Are you going to try out some new Kool ideas that you might not have seen elsewhere ? If so like what ?

The first questions that need answers are your requirements then you can start worrying about architecture and technology stacks and how to codethis or that type questions. Either way your ideas and questions are most eagerly wanted here :)

于 2009-01-19T11:17:03.590 回答
1

我不确定您使用的是什么 ORM,但我只会有一个 Posts 存储库。当我要求发表文章时,应附上所有评论(根据具体情况懒惰或急切地加载)。在 DDD 术语中,如果您想以这种方式查看它,我认为您会将其描述为 Posts 实体是“Posts”聚合的根。

不过,我认为在一个控制器中拥有两个存储库没有任何问题。

于 2009-01-19T16:47:03.643 回答
0

您可以查看示例,例如

于 2009-05-09T18:14:26.377 回答
0

您可能会对讨论 ASP.NET MVC + CSLA + DDD的一篇文章感兴趣。它提供了将它们一起使用的很好的项目示例。

于 2010-08-24T14:08:56.000 回答