简体   繁体   English

dataobjects.net 中每个页面的 select 记录

[英]select records for each page in dataobjects.net

I have lots of records in the database, and I have a control that pages those records.我在数据库中有很多记录,并且我有一个控件来分页这些记录。 How do I select records for each page?我如何为每个页面记录 select ? For example I need to select records from 51st record to 100th record.例如,我需要 select 记录从第 51 条记录到第 100 条记录。 And I can't use LINQ expressions.而且我不能使用 LINQ 表达式。 I am using dataobjects 3.9.我正在使用数据对象 3.9。 So I start as所以我开始

Query q = new Query("select SomeClass objects");

Use this query:使用此查询:

Query q = new Query("select top 100 SomeClass objects");

As far as I remember, there is no way to specify .Skip -like condition in case with DO39, so you should do this manually (eg by applying .Skip to enumerable you've got).据我记得,在 DO39 的情况下,无法指定.Skip的条件,因此您应该手动执行此操作(例如,通过将.Skip应用于您拥有的可枚举项)。

There is an obvious performance impact in this case, but it isn't essential in terms of computational complexity.在这种情况下,会产生明显的性能影响,但就计算复杂性而言,这并不是必需的。 The only effect of this is that more rows will be sent by SQL Server to the client, but all the other the job it must do remains the same.这样做的唯一效果是 SQL 服务器将向客户端发送更多行,但它必须完成的所有其他工作保持不变。

An example illustrating this:一个例子说明了这一点:

if you'll ask Google to show you 1000th page of result, it will anyway find all the document related to your query, compute match rank for each of them, sort it to get at least first 1000 of pages with best match ranks and only after all this job it will be able to give you 1000th page.如果您要求 Google 向您显示第 1000 页结果,它无论如何都会找到与您的查询相关的所有文档,计算每个文档的匹配排名,对其进行排序以获得至少前 1000 个具有最佳匹配排名的页面,并且仅在完成所有这些工作之后,它将能够为您提供第 1000 页。

So if there is 1,000,000,000,000 of documents, the computational complexity of sending 10K rows to the client is tiny in comparison with all the other job done.因此,如果有 1,000,000,000,000 个文档,与完成的所有其他工作相比,向客户端发送 10K 行的计算复杂度很小。

Also note that the whole idea of paging is to show a tiny fraction of the whole set of data.另请注意,分页的整个想法是显示整个数据集的一小部分。 So if your user needs to paginate to eg 1000th page, there is something wrong with design.因此,如果您的用户需要分页到例如第 1000 页,则说明设计有问题。 There are just two cases:只有两种情况:

  • User must get a tiny fraction of data (ie perform some search)用户必须获得一小部分数据(即执行一些搜索)
  • User must get all the data (eg to make a backup)用户必须获取所有数据(例如进行备份)

There are no intermediate cases.没有中间情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM