Share via


CrossListQueryCache Class

Manages the cache for the Cross List Query. This class cannot be inherited.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Publishing.CrossListQueryCache

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class CrossListQueryCache
'Usage
Dim instance As CrossListQueryCache
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class CrossListQueryCache

Remarks

This class caches data that is returned from the Cross List Query and applies audience targeting to the result set that is returned by the VersionCrossListQueryInfo property.

Examples

The following example code demonstrates one way to use the CrossListQueryCache object, properties, and methods. This code views data in the CrossListQueryCache object, gets the data, and stores the data in a new Content Query Web Part for viewing.

using System;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections.Generic;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.ApplicationPages;
using Microsoft.SharePoint.Publishing.WebControls;
using Microsoft.SharePoint.Publishing;

namespace CodeSampleNamespace
{
    public class CodeSample : LayoutsPageBase
    {
        protected System.Web.UI.WebControls.Panel panel;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

// CrossListQueryExample
            {
                CrossListQueryInfo crossListInfo = new CrossListQueryInfo();
                crossListInfo.ViewFields = "<FieldRef Name=\"Title\" Nullable=\"True\" Type=\"Text\"/><FieldRef Name=\"FileRef\"/>";
                crossListInfo.Query = "<Where><And><Eq><FieldRef Name=\"File_x0020_Type\"/><Value Type=\"Text\">aspx</Value></Eq>" +
                                      "<Neq><FieldRef Name=\"ContentType\"/><Value Type=\"String\">Article Page</Value></Neq></And></Where>" +
                                      "<OrderBy><FieldRef Name=\"Created\" Type=\"DateTime\" Ascending=\"True\"/></OrderBy>";
                crossListInfo.RowLimit = 15;
                crossListInfo.Webs = "<Webs Scope=\"Recursive\" />";
                crossListInfo.Lists = "<Lists ServerTemplate=\"850\">";
                crossListInfo.WebUrl = "/";

                CrossListQueryCache xlqCache = new CrossListQueryCache(crossListInfo);
                DataTable results = xlqCache.GetSiteData(SPContext.Current.Site);


                // Store the data in a new Content Query Web Part to display the results.
                ContentByQueryWebPart cbq = new ContentByQueryWebPart();
                cbq.Data = results;
                panel.Controls.Add(cbq);
               }            
           } 

   }            
} 

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

CrossListQueryCache Members

Microsoft.SharePoint.Publishing Namespace

CrossListQueryCache

CrossListQueryCache

ContextUrl

GetSiteData