我正在尝试实施此pakage
从数据库加载数据后,我将其存储为:
Session["reservations"] = futureReservations.ToDictionary(x => custIndex++, x => x);
然后我试图只获取当前页面所需的数据:
public Dictionary<int, Restaurants> GetRecordsForPage(int pageNum)
{
Dictionary<int, Restaurants> reservations = (Session["reservations"] as Dictionary<int, Restaurants>);
int from = (pageNum * RecordsPerPage);
int to = from + RecordsPerPage;
return reservations
.Where(x => x.Key > from && x.Key <= to)
.ToDictionary(x => x.Key, x => x.Value);
}
问题是即使会话信息正确,reservations
变量仍保持为空。任何人都可以帮我找出原因吗?