简体   繁体   English

CAML查询项以增量方式

[英]CAML query items in increments

I currently have a sharepoint2010 list that contains roughly 200,000 records. 我目前有一个sharepoint2010列表,其中包含大约200,000条记录。

I want to get each record, tweak it, massage it, and store it in a SQL table. 我想获取每条记录,对其进行调整,对其进行按摩,然后将其存储在SQL表中。

As of now, I am using the sharepoint 2010 web service method GetListItems like so... 截至目前,我正在像这样使用sharepoint 2010 Web服务方法GetListItems ...

System.Xml.XmlNode nodeListItems = client.GetListItems("guid", "", query, viewFields, RowNumber, queryOptions, null);

querying 200000 records is too much to query at once. 查询200000条记录太多,无法一次查询。 How can I get around this? 我该如何解决? The GetListItems method takes CAML query parameters. GetListItems方法采用CAML查询参数。

Is there a way to do this in increments, like say 5000 records at a time? 有没有办法做到这一点,例如一次说5000条记录? How would one structure the CAML query to do that? 如何构造CAML查询来做到这一点?

Unless someone has a better way of accomplishing this altogether? 除非有人完全有更好的方法来做到这一点?

Yes, there is, you can paginate the results. 是的,您可以对结果进行分页。 The fifth parameter is the page size, you have it set via RowNumber . 第五个参数是页面大小,您可以通过RowNumber设置。 Set it to 5000 if you want pages of size 5000. 如果您想要页面大小为5000,请将其设置为5000。

Details on accessing subsequent pages can be seen from the documentation for the GetListItems method 可以从GetListItems方法文档中查看有关访问后续页面的详细信息。

The GetListItems method supports server-side paging. GetListItems方法支持服务器端分页。 The XML data returned by this method includes a ListItemCollectionPositionNext attribute inside the rs:Data element that contains the information to support paging. 此方法返回的XML数据在rs:Data元素内包含ListItemCollectionPositionNext属性,该属性包含支持分页的信息。 This string contains data for the fields in the sort and for other items needed for paging. 该字符串包含排序字段中的数据以及分页所需的其他项目的数据。 You should consider this string internal and not to be modified; 您应该将此字符串视为内部字符串,而不要对其进行修改; modifying it can produce unexpected results. 对其进行修改会产生意想不到的结果。 The following example shows the form of this return value when paging is supported. 以下示例显示了支持分页时此返回值的形式。

 <rs:Data ListItemCollectionPositionNext=" Paged=TRUE&p_ID=100&View= %7bC68F4A6A%2d9AFD%2d406C%2dB624%2d2CF8D729901E%7d&PageFirstRow= 101" Count=1000 > <z:row ows_FirstName="Nancy" ows_LastName="Name" ….. /> ... </rs:Data> 

To get the next page of data, the queryOption parameter is used, as shown in the following example. 要获取下一页数据,请使用queryOption参数,如以下示例所示。

 <QueryOptions> <Paging ListItemCollectionPositionNext=" Paged=TRUE&p_ID=100&View= %7bC68F4A6A%2d9AFD%2d406C%2dB624%2d2CF8D729901E%7d&PageFirstRow= 101" /> </QueryOptions> 

So all you need to do is grab the data in that attribute from each page's result set and add it to the query to get the next page. 因此,您要做的就是从每个页面的结果集中获取该属性中的数据,并将其添加到查询中以获取下一页。

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

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