【发布时间】:2021-10-10 06:40:49
【问题描述】:
我有两个模型问题和答案
public class Question
{
public int QuestionId { get; set; }
public string QuestionContent { get; set; }
public List<Answer> Answers { get; set; }
public int QuizId { get; set; }
public Quiz Quiz { get; set; }
}
public class Answer
{
public int AnswerId { get; set; }
public string AnswerContent { get; set; }
public bool IsCorrect { get; set; }
public int QuestionId { get; set; }
public Question Question { get; set; }
}
我需要获取答案列表。我可以在测验中获得问题列表,但我不知道如何获得答案。如果与数据库设计有任何关系,我也很乐意得到一些帮助。提前致谢
【问题讨论】:
-
根据问题指南,请展示您的尝试并告诉我们您发现了什么(在本网站或其他地方)以及为什么它不能满足您的需求。
-
我曾经收到过
uow.Questions.GetAll().Where(x=>x.QuizId == id)之类的问题,实际上我还没有发现任何类似的问题。我只看到过这个stackoverflow.com/questions/23677003/…,但这不是在我的情况下存储此类数据的正确方法
标签: asp.net sql-server entity-framework-core