我正在开发一个应用程序,其模型类似于 Stack Overflow(问题/答案等...) 使用 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; }
}
所以我的文件只是一份文件,其中嵌入了“答案”
我正在尝试为这种方法设计我的存储库。
我应该有 2 个单独的存储库吗?例如:
interface IQuestionRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
}
interface IAnswerRepository
{
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}
或者是这样的:
interface IPostRepository
{
void PutQuestion(Question question);
Question GetQuestion(string questionID);
void PutAnswer(string questionID, Answer Answer);
Answer GetAnswer(string answerID);
}