Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在大数据量情况下使用Linq提高pagin计数方法的速度_C#_.net_Linq_Count_Pagination - Fatal编程技术网

C# 在大数据量情况下使用Linq提高pagin计数方法的速度

C# 在大数据量情况下使用Linq提高pagin计数方法的速度,c#,.net,linq,count,pagination,C#,.net,Linq,Count,Pagination,我有一个计数方法来对网格进行分页,返回大约200万个数字,我不想通过这样的查询来提高它的速度,但在Linq上: SELECT count(*) FROM (SELECT ROW_NUMBER() OVER (ORDER BY id) AS Row, Id FROM myTable ) t WHERE Row between 0 and (pageSize*visiblePages)+1 -- The number 1 is to check if there is another set of

我有一个计数方法来对网格进行分页,返回大约200万个数字,我不想通过这样的查询来提高它的速度,但在Linq上:

SELECT count(*)
FROM (SELECT ROW_NUMBER() OVER (ORDER BY id) AS Row, Id
FROM myTable ) t
WHERE Row between 0 and (pageSize*visiblePages)+1 -- The number 1 is to check if there is another set of 1 or more pages
我的问题是,我不需要为一个显示我有11页的页面计算200万。只检索10个结果的方法很好,但我不能用行数计数。也许你可以像这样使用LINQ的Take或Skip:


同时检查一下VS gallery的MVC寻呼机控件:

我不需要为一个显示我有11页的页面计算200万。你能说清楚一点吗?如果不计算有多少页,则不需要计数。为什么不从myTable执行select计数,然后查看计数是否为>pageSize*VisiblePages?问题是myTable的计数很慢,需要20秒以上。列是索引的,但我必须进行一些连接来进行计数。我不需要知道每一页上都有更多的页面。例如,我在DB上有30个页面,但我的当前页面显示从第1页到第10页,我不需要大于100个10页的计数,每个页面10个结果计数*不会比按id排序的行数慢