问题描述
环境:EntityFrameworkCodefirst+mvc3.0原来使用sql2005做的,后来应客户要求改成了sql2000的库结果改完之后发现mvcpager分页只能显示第一页,从第二页开始都是空白的。页码可以显示。后来尝试下面这样分页问题依然存在。varlist=products.OrderByDescending(p=>p.Sort).Skip(top_).Take(10).ToList()
下面是我捕获的第一页和第二页sql执行代码SELECTTOP10[Var_498].[ProID]AS[Internal_ProID],[Var_498].[ProName]AS[Internal_ProName],[Var_498].[ProDesc]AS[Internal_ProDesc],[Var_498].[PingPaiID]AS[Internal_PingPaiID],[Var_498].[PingPaiName]AS[Internal_PingPaiName],[Var_498].[BuJianID]AS[Internal_BuJianID],[Var_498].[BuJianName]AS[Internal_BuJianName],[Var_498].[GroupID]AS[Internal_GroupID],[Var_498].[ColorID]AS[Internal_ColorID],[Var_498].[ColorName]AS[Internal_ColorName],[Var_498].[ColorImgPath]AS[Internal_ColorImgPath],[Var_498].[CaiZhiID]AS[Internal_CaiZhiID],[Var_498].[CaiZhiName]AS[Internal_CaiZhiName],[Var_498].[ImgName]AS[Internal_ImgName],[Var_498].[Details]AS[Internal_Details],[Var_498].[Sort]AS[Internal_Sort],[Var_498].[Status]AS[Internal_Status],[Var_498].[AddTime]AS[Internal_AddTime],[Var_498].[Parent_ProID]AS[Internal_Parent_ProID]FROM(SELECT[Extent1].[ProID]AS[ProID],[Extent1].[ProName]AS[ProName],[Extent1].[ProDesc]AS[ProDesc],[Extent1].[PingPaiID]AS[PingPaiID],[Extent1].[PingPaiName]AS[PingPaiName],[Extent1].[BuJianID]AS[BuJianID],[Extent1].[BuJianName]AS[BuJianName],[Extent1].[GroupID]AS[GroupID],[Extent1].[ColorID]AS[ColorID],[Extent1].[ColorName]AS[ColorName],[Extent1].[ColorImgPath]AS[ColorImgPath],[Extent1].[CaiZhiID]AS[CaiZhiID],[Extent1].[CaiZhiName]AS[CaiZhiName],[Extent1].[ImgName]AS[ImgName],[Extent1].[Details]AS[Details],[Extent1].[Sort]AS[Sort],[Extent1].[Status]AS[Status],[Extent1].[AddTime]AS[AddTime],[Extent1].[Parent_ProID]AS[Parent_ProID]FROM[dbo].[Entity_Product]AS[Extent1]WHERE[Extent1].[ProID]>0)AS[Var_498]WHERENOT(EXISTS(SELECT[Var_500].[Internal_Sort1]AS[Internal_Sort1]FROM(SELECTTOP0[Extent1].[Sort]AS[Internal_Sort1]FROM[dbo].[Entity_Product]AS[Extent1]WHERE[Extent1].[ProID]>0ORDERBY[Extent1].[Sort]DESC)AS[Var_500]WHERE([Var_498].[Sort]=[Var_500].[Internal_Sort1])OR(([Var_498].[Sort]ISNULL)AND([Var_500].[Internal_Sort1]ISNULL))))ORDERBY[Var_498].[Sort]DESCSELECTTOP10[Var_696].[ProID]AS[Internal_ProID],[Var_696].[ProName]AS[Internal_ProName],[Var_696].[ProDesc]AS[Internal_ProDesc],[Var_696].[PingPaiID]AS[Internal_PingPaiID],[Var_696].[PingPaiName]AS[Internal_PingPaiName],[Var_696].[BuJianID]AS[Internal_BuJianID],[Var_696].[BuJianName]AS[Internal_BuJianName],[Var_696].[GroupID]AS[Internal_GroupID],[Var_696].[ColorID]AS[Internal_ColorID],[Var_696].[ColorName]AS[Internal_ColorName],[Var_696].[ColorImgPath]AS[Internal_ColorImgPath],[Var_696].[CaiZhiID]AS[Internal_CaiZhiID],[Var_696].[CaiZhiName]AS[Internal_CaiZhiName],[Var_696].[ImgName]AS[Internal_ImgName],[Var_696].[Details]AS[Internal_Details],[Var_696].[Sort]AS[Internal_Sort],[Var_696].[Status]AS[Internal_Status],[Var_696].[AddTime]AS[Internal_AddTime],[Var_696].[Parent_ProID]AS[Internal_Parent_ProID]FROM(SELECT[Extent1].[ProID]AS[ProID],[Extent1].[ProName]AS[ProName],[Extent1].[ProDesc]AS[ProDesc],[Extent1].[PingPaiID]AS[PingPaiID],[Extent1].[PingPaiName]AS[PingPaiName],[Extent1].[BuJianID]AS[BuJianID],[Extent1].[BuJianName]AS[BuJianName],[Extent1].[GroupID]AS[GroupID],[Extent1].[ColorID]AS[ColorID],[Extent1].[ColorName]AS[ColorName],[Extent1].[ColorImgPath]AS[ColorImgPath],[Extent1].[CaiZhiID]AS[CaiZhiID],[Extent1].[CaiZhiName]AS[CaiZhiName],[Extent1].[ImgName]AS[ImgName],[Extent1].[Details]AS[Details],[Extent1].[Sort]AS[Sort],[Extent1].[Status]AS[Status],[Extent1].[AddTime]AS[AddTime],[Extent1].[Parent_ProID]AS[Parent_ProID]FROM[dbo].[Entity_Product]AS[Extent1]WHERE[Extent1].[ProID]>0)AS[Var_696]WHERENOT(EXISTS(SELECT[Var_698].[Internal_Sort1]AS[Internal_Sort1]FROM(SELECTTOP10[Extent1].[Sort]AS[Internal_Sort1]FROM[dbo].[Entity_Product]AS[Extent1]WHERE[Extent1].[ProID]>0ORDERBY[Extent1].[Sort]DESC)AS[Var_698]WHERE([Var_696].[Sort]=[Var_698].[Internal_Sort1])OR(([Var_696].[Sort]ISNULL)AND([Var_698].[Internal_Sort1]ISNULL))))ORDERBY[Var_696].[Sort]DESC
解决方案
本帖最后由 liuxiang_1988 于 2012-06-08 15:50:59 编辑
解决方案二:
貌似linq的分页有个小bug你搜一下看看
解决方案三:
codefristEF不是只支持sql2005以上么///////////////////////500人淘宝客交流QQ群:185781220
解决方案四:
codefirst不支持sqlserver2000。