【发布时间】:2019-10-04 02:37:29
【问题描述】:
我有一个这样的模型:
public class MasterDoc
{
[Key]
public int MasterID {get;set;}
public string documentnumber {get;set;}
public string oYear {get;set;}
public bool isReady {get;set;} = 1
}
public class DocList
{
[Key]
public int DocListID {get;set;}
[ForeignKey("MasterDoc")]
public int MasterID {get;set;}
public MasterDoc MasterDoc {get;set;}
public DateTime? OrderDate {get;set;}
}
所以场景是,我想要一个MasterDoc 的列表(表格),表格上有复选框。当用户选中复选框时,用户单击提交按钮。它将在DocList 表上创建一条新记录,仅添加 MasterID 值。此外,MasterDoc 表上的isReady 列更新为0 或false。
目前,我有一个控制器,例如:
public ActionResult Index(string xYear)
{
var masterDocs = db.MasterDocs.Where(c => c.Year == xYear);
return View(masterDocs.ToList());
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 ef-code-first