亚音速寻呼顺序问题

发布于 2024-07-25 06:22:13 字数 991 浏览 10 评论 0原文

我有一个数据网格,我在其中使用自定义分页选项(参考:http://subsonicproject. com/querying/webcast-using-paging/)在 Subsonic 框架中。

我还有一个按州过滤数据的下拉菜单。 这通过 addwhere 调用添加到查询中。

数据按州 ASC 排序,然后按城市 ASC 排序。

当未选择任何状态时,数据似乎排序良好,因此没有将 addwhere 添加到子句中。 但是,如果您选择的状态有足够的记录来启动分页,则某些记录会乱序显示。 我还注意到,当前页面上的最后几条记录似乎总是显示在网格中间的某个位置。

loadgrid 的代码片段:

    Dim qry As New SubSonic.Query( {myTableSchema} )
    If ddlStates.SelectedValue.Trim.ToLower <> "all states" Then
        qry.AddWhere("state", ddlStates.SelectedValue.Trim)
    End If
    qry.ORDER_BY("state", "ASC").ORDER_BY("city", "ASC")
    qry.PageSize = ddlDisplay.SelectedValue
    qry.PageIndex = pageNumber
    gvOrganizers.DataSource = qry.ExecuteDataSet
    gvOrganizers.DataBind()

当选择一个状态并且只有 1 页数据时,问题似乎不会出现。 默认 ddlDisplay 设置为每页 100 条记录,但即使选择 50 或 25 条也会出现错误。

使用亚音速 2.1.0.0

I have a datagrid where I am using the custom paging option (ref: http://subsonicproject.com/querying/webcast-using-paging/) in the Subsonic framework.

I also have a dropdown that filters the data by State. This is added to the query through the addwhere call.

the data is ordered by state ASC and then city ASC.

the data seems to be ordered fine when no state is selected and thus no addwhere is added to the clause. But if you select a state that has enough records to cause pagination to kick in, then some records are displayed out of order. I have also noticed that it always seems to be the last few records on the current page are displayed somewhere in the middle of the grid.

snippet of code to loadgrid:

    Dim qry As New SubSonic.Query( {myTableSchema} )
    If ddlStates.SelectedValue.Trim.ToLower <> "all states" Then
        qry.AddWhere("state", ddlStates.SelectedValue.Trim)
    End If
    qry.ORDER_BY("state", "ASC").ORDER_BY("city", "ASC")
    qry.PageSize = ddlDisplay.SelectedValue
    qry.PageIndex = pageNumber
    gvOrganizers.DataSource = qry.ExecuteDataSet
    gvOrganizers.DataBind()

The problem doesn't seem to appear when a state is selected and there is only 1 page of data. Default ddlDisplay setting is 100 records per page but the error appears even if 50 or 25 is chosen.

Using Subsonic 2.1.0.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

未蓝澄海的烟 2024-08-01 06:22:13

使用 qry.OrderAsc(New String(){"state asc, city asc"})

Use qry.OrderAsc(New String(){"state asc, city asc"})

岛歌少女 2024-08-01 06:22:13

PAGING_VIEW_SQL 模板中似乎存在错误(SqlProvider.cs,第 1702 行)。 以下是代码片段:

...
SELECT _indexID = IDENTITY(int, 1, 1), {1} INTO #temp FROM {0} WHERE 1 = 0
INSERT INTO #temp ({1}) SELECT {1} FROM {0} {2} {3}

SELECT * FROM #temp
WHERE _indexID BETWEEN ((@Page - 1) * @PageSize + 1) AND (@Page * @PageSize)

--clean up  
DROP TABLE #temp", where {3} represents serialized order-by-collection.

您可以看到,首先排序的数据被排序并插入到临时表中,但随后检索所需的页面而无需再次排序。 最终导致为请求的页面获取正确的数据,但没有正确的排序。

需要修改第二个 select ,以便从临时表中获取数据时顺序正确。 像这样:

SELECT * FROM #temp    
WHERE _indexID BETWEEN ((@Page - 1) * @PageSize + 1) AND (@Page * @PageSize) {3}

当然,然后重新编译代码就可以了:-)

There seems to be a bug in PAGING_VIEW_SQL template (SqlProvider.cs, line 1702). Here is the snippet:

...
SELECT _indexID = IDENTITY(int, 1, 1), {1} INTO #temp FROM {0} WHERE 1 = 0
INSERT INTO #temp ({1}) SELECT {1} FROM {0} {2} {3}

SELECT * FROM #temp
WHERE _indexID BETWEEN ((@Page - 1) * @PageSize + 1) AND (@Page * @PageSize)

--clean up  
DROP TABLE #temp", where {3} represents serialized order-by-collection.

You can see that at first ordered data is sorted and inserted into a temp table but than the required page is retrieved without sorting again. Which in the end results in getting the right data for the requested page but without proper sorting.

The second select needs to be modified so that the data is in the correct order when it is taken from the temp table. Like this:

SELECT * FROM #temp    
WHERE _indexID BETWEEN ((@Page - 1) * @PageSize + 1) AND (@Page * @PageSize) {3}

and then of course recompile the code and off you go :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文