嗨,我是 MVC 4 的新手,我想创建一个验证应用程序,我的类之一是:
public partial class Division
{
public Division()
{
this.Id = Guid.NewGuid();
this.Persons = new HashSet<Person>();
this.DevisionContnets = new HashSet<DevisionContnet>();
}
public System.Guid Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Person> Persons { get; set; }
public virtual ICollection<DevisionContnet> DevisionContnets { get; set; }
public virtual DateTime InsertDate { get; set; }
public Nullable<System.DateTime> UpdateDate { get; set; }
public Nullable<System.Guid> InsertUid { get; set; }
public Nullable<System.Guid> UpdateUid { get; set; }
public string UpdateStatment { get; set; }}
我不想让用户看到插入或更新属性,我只是为了监控!当我从脚手架视图中删除它们时,它给我一个错误指示内部异常 datetime 2 out of range 例如我在编辑或创建视图中所做的事情:
<fieldset>
<legend>Division</legend>
@Html.HiddenFor(model => model.Id)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
那么为什么我得到一个错误并且我的对象将日期返回到 01/01/0001?