我用控件mvcpager+Linq to sql类可以实现分页;但是我想用.net实体类+mvcpager来实现,运行的时候总是报错:
- C# code
public ActionResult CustomerInf(int? id) { PagedList<CustomerInf> customer = db.CustomerInf.ToPagedList(id ?? 1, 5);//这里老是报错 return View(customer); //var customer = from m in db.CustomerInf select m; //return View(customer.ToList()); }
错误提示:仅对 LINQ to Entities 中已排序的输入支持方法“Skip”。必须在调用“Skip”方法之前调用方法“OrderBy”。
请教?
------解决方案--------------------------------------------------------
PagedList<实体> li = new PagedList<实体>(实体集合, pageIndex, pageSize, TotalRecord);
------解决方案--------------------------------------------------------
在调用Skip之前orderby 一下