在Web应用程序分页效率 [英] Efficient paging in Web Application

查看:111
本文介绍了在Web应用程序分页效率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Web应用程序分页。我在网上搜索,发现很多教程上的分页网站(创建新VS网站)。我不能使用VS其中启用分页电流的方法可以轻松完成,因为它的效率不高和放大器;从数据库中检索数据的整个表。

I'm new to paging in web applications. I searched the web and found lots of tutorial on paging for web site(Create new website in VS). I cant use the current method of enable paging in vs which can be done easily because its not efficient & retrieve the whole table of data from database.

默认分页可以通过只检查启用Web数据控件的智能标签分页选项来实现。然而,无论何时查看数据的一个页面中,ObjectDataSource检索所有的记录,即使只有其中的一个子集被显示在页面

Default paging—Can be implemented by just checking the Enable Paging option in the data Web control's smart tag. However, whenever viewing a page of data, the ObjectDataSource retrieves all of the records, even though only a subset of them is displayed in the page.

定制寻呼提高默认分页通过检索仅从必须显示用于由用户请求的数据的特定页的数据库的记录的性能。然而,自定义分页涉及比默认分页实现多一点努力。

Custom paging—Improves the performance of default paging by retrieving only those records from the database that must be displayed for the particular page of data requested by the user. However, custom paging involves a bit more effort to implement than default paging.

我要找的web应用程序自定义分页,希望你们能帮我了。
我发现了2个链接,我认为可能是自定义分页,但我不知道该code的一部分这么说,所以这将是很好,如果你能告诉我其中$​​ C $ C的一部分,实际上使其高效谢谢!

I'm looking for a custom paging for web application, hope you guys can help me with it. I found 2 links which i think might be custom paging but i'm not sure which part of the code say so, so it would be nice if you can tell me which part of the code actually make it efficient Thanks!

2.链接
http://www.$c$cproject.com/Articles/170921/MvcContrib-Grid-Paging-and-Searching-in-ASP-NET-MV

<一href=\"http://blogs.msdn.com/b/$c$cfx/archive/2009/09/07/how-to-implement-insert-edit-delete-paging-and-sorting-functions-in-an-asp-net-gridview-control.aspx?CommentPosted=true#commentmessage\" rel=\"nofollow\">http://blogs.msdn.com/b/$c$cfx/archive/2009/09/07/how-to-implement-insert-edit-delete-paging-and-sorting-functions-in-an-asp-net-gridview-control.aspx?CommentPosted=true#commentmessage

再次感谢!

推荐答案

我不相信无论您的链接展示efficent分页

I'm not convinced either of your links demonstrate efficent paging

链接1 - LINQ的例子
为了使这是effificent我希望看到的东西的形式

link 1 - the LINQ example In order for this to be effificent I would expect to see something in the form

var myDataSource = data.Select(x => x.Parameter = "input").Skip(1).Take(10);

其原理是跳跃,并采取方法只检索所需数据的页

The principle is that the skip and take methods just retrieve the page of data that you want

<一个href=\"http://blogs.msdn.com/b/$c$cfx/archive/2009/09/07/how-to-implement-insert-edit-delete-paging-and-sorting-functions-in-an-asp-net-gridview-control.aspx?CommentPosted=true#commentmessage\"相对=nofollow>链接2 - 在SQL实例

link 2 - the SQL Example

同样不相信 - 我希望看到的东西在使用 ROW_OVER()或SQL的一些其他证据只带回的数据页面的SQL你想。这<一个href=\"http://blog.sqlauthority.com/2007/06/11/sql-server-2005-t-sql-paging-query-technique-comparison-over-and-row_number-cte-vs-derived-table/\"相对=nofollow>链接给出了使用ROW_OVER与SQL Server的实例2005年(2008年可能会有所改善 - 我不知道TBH - 其他人可能和我有兴趣)。

Again not convinced - I would expect to see something in the SQL that uses ROW_OVER() or some other evidence of the SQL only bringing back the page of data that you want. This link gives an example of using ROW_OVER with SQL Server 2005 (2008 might have improved - i don't know TBH - someone else might and i would be interested).

一般

我有ASP.Net 3.5或更高版本我会使用LINQ的例子 - 它的很多更直接的比试图做到这一点在SQL

I you have ASP.Net 3.5 or higher I would use the LINQ example - it's a lot more straight forward than trying to do it in SQL

这<一个href=\"http://mosesofegypt.net/post/Building-Custom-Paging-with-LINQ2c-ListView2c-DataPager-and-ObjectDataSource.aspx\"相对=nofollow>链接使用LINQ的采取和跳过运营商做有效的寻呼与一个ListView给出了一个更好的例子。它还涉及有为了显示的页数这是一个共同的要求,您可以得到记录总数的问题。

This link gives a better example using LINQ with the Take and Skip operators to do efficient paging with a ListView. It also addresses the issue of having to get a total count of your records in order to display the number of pages which is a common requirement.

此外 - 这 SO问题给出了高效的分页一些非常好的例子,所以我不建议您阅读。

Also - this SO question gives some very good examples of efficient paging so I do recommend you read that.

LINQ注意

由于下面的评论者指出的 - 你需要确保跳过并采取正在实现对数据库而不是整个数据集正在执行,勾起以及跳过和客户端上执行就拿。探查这里是你的朋友。另外值得一知道哪个运营商实现查询和火它关闭到数据库中。

As the commenter below pointed out - you need to ensure that skip and take are executing on the DB not the entire dataset being realised, brought back and the Skip and Take executing on the client. Profiler is your friend here. Also is worth knowing which operators realise the query and fire it off to the database.

var myDataSource = data.Select(x => x.Parameter = "input").Skip(1).Take(10);

上面大概确定

var myDataSource = data.Select(x => x.Parameter = "input")
                                  .ToList().Skip(1).Take(10);

哎呀没有好。该了ToList()方法会导致SQL来跳过前被解雇掉到数据库,并以做它的工作。

Ooops no good. The ToList() method will cause the SQL to be fired off to the database before Skip and Take has done it's work.

这篇关于在Web应用程序分页效率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆