How to get the nth record (lets say 133rd) from the 1000 records (or unknown number of records) by using CAML query.
|
as said in above reply you can get specific no. of records using RowLimit. TO get nth record only you can use "ID" field to get specific reocrd. i.e Where ID = "your number" before firing query to retrive the nth make sure list contains n no. of records Regards, Ketan |
|||||
|
|
You could use RowLimit
|
|||||
|
|
You would need to figure out what qualifies the "133rd" record? Is is the ID (most cases, but not reliable as it does functions like in SQL database for auto-incremented column), is it the last modified date, created date, etc. What I've used to do was to use an OrderBy numeric column (0 decimals - so it integer) that I've always sorted after. Once this is established you could even combine multiple clauses to get closer to your record, via OrderBy and Where, see here explanations http://weblogs.asp.net/uruit/archive/2010/06/15/how-to-add-new-filters-to-caml-queries-in-sharepoint-2007.aspx Once you get your results back, just use LINQ to get your Last(), see here something similar Getting items from rows 4-8 in a Sharepoint list using CAML query? Recomandations for large lists are to use in your Query any of the ContentIterator.ItemEnumerationOrderByID, ContentIterator.ItemEnumerationOrderByPath, or ContentIterator.ItemEnumerationOrderByNVPField in the OrderBy clause, see here for more http://msdn.microsoft.com/en-us/library/ee558807(v=office.14) |
|||
|
|
|
Do you have any kind of identifier of that record? If so, just use Where clausule to select 1 record. If not, you should just specify some argument in Where clausule to filter records (if possible), use Order By (if needed) and of course use RowLimit set to value of "n" and then use linq to get .Last() item in result set. Yes, you will get "n" results but if you have no specific identifier for your record there is no other option. If you need more help, try to be more specific about your scenario - eg. why you need nth record. |
|||
|
|
