With MOSS 2007 or SharePoint Server 2010 you can use the PoraltSiteMapProvider of the Microsoft.SharePoint.Publishing.dll assembly to retrieve cached listitems.

<span style="color:#606060" id=lnum1>   1:</span> PortalSiteMapProvider ps = PortalSiteMapProvider.WebSiteMapProvider;
<span style="color:#606060" id=lnum2>   2:</span> var pNode = ps.FindSiteMapNode(web.ServerRelativeUrl) as PortalWebSiteMapNode;
<span style="color:#606060" id=lnum3>   3:</span> var query = new SPQuery
<span style="color:#606060" id=lnum4>   4:</span>                {
<span style="color:#606060" id=lnum5>   5:</span>                   Query = "<Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where>"
<span style="color:#606060" id=lnum6>   6:</span>                };
<span style="color:#606060" id=lnum7>   7:</span> SiteMapNodeCollection quoteItems = ps.GetCachedListItemsByQuery(pNode, "Top Seiten", query, web);

In my case, I didn’t need any special where clause. I wanted to retrieve all items, so I left the Query property  empty. And because I needed only three columns, I specified the ViewFields property of the SPQuery object.

Bad idea. The query failed hard and fast 🙂


If you use the GetCachedListItemsByQuery method, do not specify the ViewFields property of the SPQuery and configure a query. Even if it returns all items of the list!