[英]having difficulty searching for a date
我在搜索日期列表时遇到问题,搜索结果没有出现。 变量约会日期已作为日期时间保存在数据库中。 这是我目前在控制器中的代码:
public ActionResult Index(DateTime SearchDate)
{
var query = from a in db.AppointmentProcedures
where a.BookingStatus == false
orderby a.AppointmentStartTime
select a;
if (SearchDate != null)
{
query = from a in db.AppointmentProcedures
orderby a.AppointmentDate
where a.AppointmentDate <= SearchDate
select a;
}
return View(query);
}
这是我继续遇到的错误:
The model item passed into the dictionary is of type
'System.Data.Entity.Infrastructure.DbQuery`1[System.DateTime]', but this dictionary
requires a model item of type
'System.Collections.Generic.IEnumerable`1[LaserculptFinal.Models.AppointmentProcedure]'
看起来您想将model
List
传递给您的model
,但是您正在传递查询,因为您没有像这样列举它。
public ActionResult Index(DateTime SearchDate)
{
.....
return View(query.ToList());
}
如果您向我们展示了您的视图所需的模型,这将有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.