我有一点问题,这是我的代码:
public partial class Tourist
{
public Tourist()
{
Reserve = new HashSet<Reserve>();
}
public int touristID { get; set; }
[Required]
[StringLength(50)]
public string touristNAME { get; set; }
public DateTime touristBIRTHDAY { get; set; }
[Required]
[StringLength(50)]
public string touristEMAIL { get; set; }
public int touristPHONE { get; set; }
public virtual ICollection<Reserve> Reserve { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我如何限制touristBIRTHDAY为+18岁?我想我必须使用这个函数,但我不知道把它放在哪里:注意:这个函数就是一个例子.
DateTime bday = DateTime.Parse(dob_main.Text);
DateTime today = DateTime.Today;
int age = today.Year - bday.Year;
if(age < …Run Code Online (Sandbox Code Playgroud)