【发布时间】:2015-02-19 05:55:08
【问题描述】:
我正在尝试将分页应用于我的 MVC 应用程序。我正在使用 Azure 表存储
这是我尝试过的:-
public List<T> GetPagination(string partitionKey, int start, int take)
{
List<T> entities = new List<T>();
TableQuery<T> query = new TableQuery<T>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey.ToLower()));
entities = Table.ExecuteQuery(query).Skip(start).Take(take).ToList();
return entities;
}
控制器:-
public ActionResult Index()
{
key= System.Web.HttpContext.Current.Request[Constants.Key];
if (String.IsNullOrEmpty(key))
return RedirectToAction("NoContext", "Error");
var items= _StorageHelper.GetPagination(key,0,3);
ItemCollection itemCollection = new ItemCollection();
itemCollection .Items= Mapper.Map<List<ItemChart>, List<ItemModel>>(items);
itemCollection .Items.ForEach(g => g.Object = g.Object.Replace(key, ""));
return View(itemCollection);
}
这目前为我提供了数据中的前 3 个条目。现在如何显示和实现“上一个”和“下一个”以在下一页显示其余条目?如何实现控制器和 HTML 页面的其余部分?
感谢任何帮助。
【问题讨论】:
标签: asp.net-mvc azure pagination