我正在开发一个类似于Stack Overflow的应用程序(问题/答案等)。模型看起来像这样(简化):
使用C# / ASP.net MVC建模NoSQL论坛应用程序
使用C# / ASP.net MVC建模NoSQL论坛应用程序
class Question
{
public string Title { get; set; }
public string Body { get; set; }
public DateTime DateCreated { get; set; }
public string UserName { get; set; }
public List<Answer> Replies { get; set; }
}
class Answer
{
public string Body { get; set; }
public DateTime DateCreated { get; set; }
public string UserName { get; set; }
}
我的文档只是一个文档,其中包含了“答案”。
我正在尝试为这种方法设计我的代码库。
我应该有两个单独的代码库吗?例如:
interface IQuestionRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
}
interface IAnswerRepository
{
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}
Or something like this:
interface IPostRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}