【发布时间】:2013-10-07 11:27:19
【问题描述】:
我在搜索日期列表时遇到问题,没有显示搜索结果。可变约会日期已作为日期时间保存在数据库中。这是我目前在我的控制器中的代码:
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]'
【问题讨论】:
-
在我看来这不像 FORTRAN。
-
错误在哪里?在视图中?扔进控制器?如果不使用
SearchDate,它是否有效? -
您是否尝试过在查询中使用 ToList()?
-
是的,我已经尝试过 ToList 并且给我构建错误的代码行是: where a.AppointmentDate == Convert.ToString(SearchDate)
标签: c# asp.net-mvc search