【发布时间】:2021-04-28 09:59:54
【问题描述】:
我正在尝试创建一个问题表,其中包含描述性和选择以及是否问题,并且我想将所有问题插入一个表中。 当我想创建选择问题时,我想使用 enum 和 json 将选择插入表中,就像 YesNo 问题一样。我也想选择问题表的正确答案。我怎样才能做到这一点? 这是我的问题课:
public class Question
{
[Key]
public int Id { get; set; }//1
public int CourseId { get; set; }
public string QuestionTitle { get; set; }
public decimal Grade { get; set; }
public DateTime TimeDuration { get; set; }
public DateTime StartTime { get; set; }
[EnumDataType(typeof(Choice))]
public string Choice { get; set; }
public string CorrectChoice { get; set; }
[EnumDataType(typeof(YesNo))]
public bool? YesNo { get; set; }
public string Descriptive { get; set; }
#region relations
public virtual IdentityUser IdentityUser { get; set; }
public Course course { get; set; }
#endregion
}
public enum Choice
{
Choice1, Choice2, Choice3, Choice4
}
public enum YesNo
{
Yes, No
}
当我尝试为问题创建单独的表(描述表、YesNo 表、选择表)时,我的主管说这是不对的,您应该按照上述方式进行操作。
【问题讨论】:
-
您能解释一下您当前尝试的问题是什么吗?
-
我不知道如何将问题选项插入表格。
标签: c# asp.net json asp.net-core enums