这是我的模型课程:[Table("Question", Schema = "trs")]public class Question{ [Key] public int QuestionId { get; set; } [ForeignKey("TranType")] [Required] public int TranTypeId { get; set; } [ForeignKey("Company")] [Required] public int CompanyId { get; set; } [Required] [StringLength(300)] public string Text { get; set; } [Required] public bool IsActive { get; set; } [ForeignKey("QuestionType")] public int QTypeId { get; set; } public DateTime CreatedDate { get; set; } public string CreatedUserId { get; set; } public DateTime UpdateDate { get; set; } public string UpdateUserId { get; set; } public Company Company { get; set; } public QuestionType QuestionType { get; set; } public TranType TranType { get; set; } public ICollection<Answer> Answer { get; set; } public ICollection<Grading> Grading { get; set; }}这是我的控制器操作,现在它什么也不做,因为我需要首先获取出现问题的值:[Authorize(Roles = "Admin")]public class QuestionController : Controller{ readonly IQuestionRepository questionRepository; readonly ICompanyRepository companyRepository; public QuestionController(IQuestionRepository qRepository, ICompanyRepository cpnRepository) { questionRepository = qRepository; companyRepository = cpnRepository; } [HttpPost] public ActionResult Save([FromBody] List<Question> qView) { return View(qView); }}现在我也尝试过: [HttpPost] public ActionResult Save(List<Question> qView) { return View(qView); }在这两种情况下,我都有问题;在第一个选项中(带有[FromBody]),qView为null;在选项2中(没有[FromBody]),qView不为null,但List为空(Count == 0)。请问我的问题在哪里?
2 回答
- 2 回答
- 0 关注
- 175 浏览
添加回答
举报
0/150
提交
取消