SQL Server CE(精简版)中的数据分页 [英] Data paging in SQL Server CE (Compact Edition)

查看:106
本文介绍了SQL Server CE(精简版)中的数据分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写wpf停止应用程序,并且想使用SQL Server CE作为后端.我正在尝试提出一种有效的数据分页的好方法.在SQL Server Express中,我可以执行以下操作:

I am writing a wpf destop application, and would like to use SQL Server CE as a backend. I'm trying to come up with a good way to do efficient data paging. In SQL Server Express, I can do something like this:

Select ID, FirstName, LastName
From (SELECT  ROW_NUMBER() OVER (ORDER BY ID)
 AS Row, ID, FirstName, LastName
 From TestTable                             
) 
WHERE  Row > 1 AND Row <= 10    

SQL Server CE中有什么可比的吗?我不确定是什么,不支持什么.我只想一次只从数据库返回10行,而不必拉回所有数据,然后向下过滤以显示给用户,因为这要慢得多.谢谢.

Is there anything comparable in SQL Server CE? I'm not completely sure what is and is not supported. I want to only return 10 rows at a time from the database, and not have to pull back all the data and then filter it down to display to the user, since that is much slower. Thanks.

推荐答案

老实说,可能最快的方法是使用 SqlCeResultSet 支持

Honestly, probably the fastest thing to do is use an SqlCeDataReader and call .Read() 10 times. Then when the user moves to the next page, you're already pointing at the 11th result, and can read 10 more. If you need to go backwards, you can either cache your results or switch to an SqlCeResultSet which supports seeking.

根据经验,SqlCeDataReader/Result是与桌面上的数据库进行交互的绝对最快的方法.实际上,它可以比使用DataSets/DataAdapters快100倍.

Also, SqlCeDataReader/Result is, from experience, the absolute fastest way to interact with the database on the desktop. It can be literally 100 times faster than using DataSets/DataAdapters.

这篇关于SQL Server CE(精简版)中的数据分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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