如何编写获取该记录的代码通过传递Date,MM,Year,HH,MM,SS 所有这些参数都来自DropdownList
public JsonResult Dif(int Day = 0, int Month=0, int Year=0, int HH, int MM, int Ss)
{
var x = (from n in db.Employees
where n.DataofBirth = (Day,Month,Year)
select n).First();
return new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
答案 0 :(得分:2)
您需要创建DateTime
的实例:
var date = new DateTime(Year, Month, Day, HH, MM, Ss);
var x = (from n in db.Employees
where n.DataofBirth = date
select n).First();
此外,参数具有默认值并不合理......特别是如果它不是有效值!年,月或日都不能为0。