Friday, June 13, 2008

Default RowLimit in SPQuery

Fumbled upon a strange behavior when using "SPQuery". Used SPQuery in one of the places and found that it is not returning all the results from the List queried !!!!


There was no way of debugging to locate the culprit until some SDK documentation came to rescue saying that the default resultset rowlimit for SPQuery is 100.

So make it a point to explicitly set it to some higher number :
query.RowLimit = 500;

When using "Lists" webService available in MOSS 2007, GetListItems has a parameter rowlimit which would allow to set this rowlimit.

Also when using SPQuery it bydefault would search only the current folder in the List. WSS v3.0 allows to search all subfolders in the same query using :
query.ViewAttributes = "Scope=\"Recursive\"";

This is especially important when querying Discussion Board list as it uses Folder hierarchy to store all the replies for a particular topic.

1 comments:

Anonymous November 12, 2010 at 12:35 PM  

Nice Tips Laxmi..

Mahesh