由于分页问题导致服务器错误
我想我整理了我的 GridView1_PageIndexChanged 事件并认为它应该起作用
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.DataSourceID = "lqPackWeights";
GridView1.PageIndex = e.NewPageIndex;
}
但是,当我现在尝试访问 x 的第 2 页时,我收到以下消息:
“/project”应用程序中的服务器错误。 此提供程序仅在返回包含所有标识列的实体或投影的有序查询上支持 Skip(),其中查询是单表(非联接)查询,或者是 Distinct、Except、Intersect 或 Union(不是 Concat)手术。
我对此有点困惑,据我所知,我没有使用跳过,除非我失明了?
我当前使用的是 SQL2000,这是与此 SQL 实例直接相关的问题吗?
I think I sorted out my GridView1_PageIndexChanged event and thinking it should work
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.DataSourceID = "lqPackWeights";
GridView1.PageIndex = e.NewPageIndex;
}
However, when I now attempt to access page 2 of x, I receive the following:
Server Error in '/project' application.
This provider supports Skip() only over ordered queries returning entities or projections that contain all identity columns, where the query is a single-table (non-join) query, or is a Distinct, Except, Intersect, or Union (not Concat) operation.
I'm a bit confused by this, I'm not using skip as far as I can see unless I am going blind?
I am currently using SQL2000, is this a problem directly related to this instance of SQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用 LINQ to SQL 吗?该问题似乎是 SQL Server 2000 所特有的。请参阅有关疑难解答 (LINQ to SQL) 和标准查询运算符转换 (LINQ to SQL) 了解更多信息。
编辑
以前曾提出过类似的问题,请参阅: LINQ、Skip、OrderBy 和 SQL Server 2000
Are you using LINQ to SQL? The problem seems unique to SQL Server 2000. See these MSDN articles on Troubleshooting (LINQ to SQL) and Standard Query Operator Translation (LINQ to SQL) for more information.
EDIT
A similiar question has been asked before, see: LINQ, Skip, OrderBy, and SQL Server 2000
该控件使用 Skip 来获取它应该显示的特定页面的记录。
在 SQL Server 中,没有默认的查询顺序(除非它是具有聚集索引的直接表),因此您必须在数据源的查询中指定顺序。查询的结果必须有特定的顺序;如果顺序从一页到另一页发生变化,那么对结果进行分页是没有意义的,这样您就可以从每页的结果中或多或少地随机选择记录。
The control is using Skip to get to the records for the specific page that it is supposed to display.
In SQL Server there is no default ordering for queries (unless it's a direct table with a clustered index), so you have to specify an order in the query for the data source. The result of the query has to have a specific ordering; it doesn't make sense to page through a result if the ordering changes from page to page so that you get more or less a random pick of records from the result for each page.
目前我的 linq 查询已排序...我想这不是前进的方向,还是我误解了你?
私有对象 GetMaterialData(字符串 MemberKey, 字符串 MaterialType, 字符串 MaterialLevel, int Count)
{
ORWeightsDataClassesDataContext db = newORWeightsDataClassesDataContext();
var query = db.tblOnlineReportingCOMPLETEWeights
.Where(x => x.MaterialLevel == MaterialLevel && x.MaterialText == MaterialType && x.MemberId == MemberKey)
.OrderByDescending(x => x.ProductPercentage).Take(Count);
返回查询;
}
Currently my linq query is ordered...I guess that is not the way forward or am I misunderstanding you?
private object GetMaterialData(string MemberKey, string MaterialType, string MaterialLevel, int Count)
{
ORWeightsDataClassesDataContext db = newORWeightsDataClassesDataContext();
var query = db.tblOnlineReportingCOMPLETEWeights
.Where(x => x.MaterialLevel == MaterialLevel && x.MaterialText == MaterialType && x.MemberId == MemberKey)
.OrderByDescending(x => x.ProductPercentage).Take(Count);
return query;
}