我在搜索日期列表時遇到問題,搜索結果未顯示。變量約會日期已作爲日期時間保存在數據庫中。這是代碼我現在有在我的控制器:難以搜索日期
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',它會起作用嗎? – JLe
您是否嘗試過在查詢中使用ToList()? – Andrew