I have an requirement of fetching bulk data from sharepoint list using SPquery. Here is the code

DataTable dt=new DataTable();
SPQuery query = new SPQuery();
query.ViewAttributes = "Scope=\"SiteCollection\"";
query.Query = "<Where><Eq><FieldRef Name='Title'><Value Type='Text'>s</Value></Eq></Where>";
query.ViewFields = "<FieldRef Name='Title'>";
query.ViewFieldsOnly = true;
query.QueryThrottleMode = SPQueryThrottleOption.Strict;
splist.EnableThrottling = false;
query.RowLimit = 2000;
                            SPListItemCollection myItems = splist.GetItems(query);
                            if (dt == null || dt.Rows.Count <= 0)
                                dt = myItems.GetDataTable();
                            query.ListItemCollectionPosition = myItems.ListItemCollectionPosition;
                        while (query.ListItemCollectionPosition != null);

If I didn't set splist.EnableThrottling = false I am unable to retrieve bulk data from sharepoint list. Programatically If I have set the splist.EnableThrottling = false I am getting Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack error,I have gone through the msdn article http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.enablethrottling.aspx.This property requires Farm Admin Permission.

So how could I retrieve bulk data without using splist.enablethrottling property.Could anyone help me to solve this issue ?

2 Answers 2


SharePoint Server 2010 provides a new class named ContentIterator that you can use to query lists without hitting these limits. You should consider using this class if you need to run a query that will return more than 5,000 rows of data.


You can use cycle with paging. Get 1000 items and add it to DataTable while query.ListItemCollectionPosition isn't null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.