【发布时间】:2014-05-31 17:26:36
【问题描述】:
我一直在尝试在这样的 linq 查询中使用日期:
public ActionResult GetSchedule(string selectedDate)
{
DateTime daySearch = Convert.ToDateTime(selectedDate);
viewModel.Assignments = from a in db.Assignments where a.teacherId == intTeacherId select a;
问题是我的数据库中的日期格式看起来我的数据库日期看起来像这样
“2014-05-26 00:00:00.0000000”和我的 ajax 调用日期如下所示...5/26/2014:12:00:00 AM。
我尝试了一个看起来像……的请求
var allTeacherSchecules = from x in db.Assignments where x.teacherId == intTeacherId select x;
viewModel.Assignments = from ss in allTeacherSchecules where allTeacherSchecules Contains(selectedDate) select ss;
...这样我就不必担心特定的匹配,但“包含”在这里不起作用。
如何让我的 ajax 请求日期格式与我的数据库日期格式相匹配?
【问题讨论】: