我的问题与这个问题和答案有关
以下复杂模型:
public class EditSubmissionModel
{
public string foo { get; set; }
public Submission submission { get; set; }
}
简单的模型
[Table(Name = "Submission")]
public class Submission
{
[Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
public int SubmissionId { get; set; }
[Column]
public string Title { get; set; }
}
风景:
@model Project.WebUI.Models.EditSubmissionModel
@{
ViewBag.Title = "editSubmission";
}
<h2>editSubmission</h2>
@using (Html.BeginForm())
{
<legend>SubmissionModel</legend>
@Html.EditorFor(m => m.foo)
@Html.EditorFor(m => m.submission)
<input type="submit" value="Save" />
}
编辑器模板
@model Project.Domain.Entities.Submission
@Html.EditorFor(m => m.Title)
控制器
[Authorize]
[HttpPost]
public ActionResult editSubmission(string shortName, EditSubmissionModel model)
{
shortname = "second" (is ok)
model.foo = aaa (also ok i edited it on the view)
model.submission = null (not binded? or i dont know?)
我看不到错误,有什么想法吗?