CrossListQueryCache CrossListQueryCache CrossListQueryCache Class

Definition

Manages the cache for the Cross List Query.

public ref class CrossListQueryCache sealed
public sealed class CrossListQueryCache
Public NotInheritable Class CrossListQueryCache
Inheritance
CrossListQueryCacheCrossListQueryCacheCrossListQueryCache

Examples

<p>The following code example demonstrates one way to use the <strong>CrossListQueryCache</strong> object, properties, and methods. This code views data in the <strong>CrossListQueryCache</strong> object, gets the data, and stores the data in a new Content By Query Web Part for viewing.</p>
<pre><code>using System;

using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Publishing.WebControls; using Microsoft.SharePoint; using System.Web;

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // GetSiteDataResults(Microsoft.SharePoint.SPSite,System.Boolean) ExampleOne(); // GetSiteDataResults(Microsoft.SharePoint.SPSite,System.String,System.Boolean) ExampleTwo(); //GetSiteDataResults(Microsoft.SharePoint.SPWeb,Microsoft.SharePoint.SPSiteDataQuery,System.Boolean) ExampleThree(); // GetSiteDataResults(Microsoft.SharePoint.SPWeb,System.Boolean) ExampleFour();

    }


    //GetSiteDataResults(Microsoft.SharePoint.SPSite,System.Boolean)
    // Returns the results of the current query on the specified site.  The query will be run against
    // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a site or web

    // This version of GetSiteDataResults uses the web url in this object's CrossListQueryInfo to determine
    // either the web to query against or the web of the list being queried against depending on the value
    // of useSpQueryOnList.
    private static void ExampleOne()
    {
        using (SPSite site = new SPSite("http://adventure-works"))
        {
            //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
            ContentByQueryWebPart cbq = new ContentByQueryWebPart();
            CbqQueryVersionInfo versionInfo = cbq.BuildCbqQueryVersionInfo();
            CrossListQueryInfo queryInfo = versionInfo.VersionCrossListQueryInfo;
            // Create a new CrossListQueryCache object with the queryInfo we just got
            CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);

            SiteDataResults results = crossListCache.GetSiteDataResults(site, false);
        }
    }


    // GetSiteDataResults(Microsoft.SharePoint.SPSite,System.String,System.Boolean)
    // Returns the results of the current query on the specified site.  The query will be run against
    // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a site or web

    // This version of GetSiteDataResults uses the webUrl parameter to determine
    // either the web to query against or the web of the list being queried against depending on the value
    // of useSpQueryOnList.
    private static void ExampleTwo()
    {
        using (SPSite site = new SPSite("http://adventure-works"))
        {
            //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
            ContentByQueryWebPart cbq = new ContentByQueryWebPart();
            CbqQueryVersionInfo versionInfo = cbq.BuildCbqQueryVersionInfo();
            CrossListQueryInfo queryInfo = versionInfo.VersionCrossListQueryInfo;
            // Create a new CrossListQueryCache object with the queryInfo we just got
            CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);
            // GetSiteDataResults(Microsoft.SharePoint.SPSite,System.String,System.Boolean)
            SiteDataResults results = crossListCache.GetSiteDataResults(site, "/", false);
        }
    }


    //GetSiteDataResults(Microsoft.SharePoint.SPWeb,Microsoft.SharePoint.SPSiteDataQuery,System.Boolean)
    // Returns the results of the passed in query parameter on the specified web or list. The query will be run against
    // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a web

    // This version of GetSiteDataResults uses object's member SPSiteDataQuery
    private static void ExampleThree()
    {
        using (SPSite site = new SPSite("http://adventure-works"))
        {
            //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
            ContentByQueryWebPart cbq = new ContentByQueryWebPart();
            CbqQueryVersionInfo versionInfo = cbq.BuildCbqQueryVersionInfo();
            CrossListQueryInfo queryInfo = versionInfo.VersionCrossListQueryInfo;
            // Create a new CrossListQueryCache object with the queryInfo we just got
            CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);
            // Use the cossListCache to create an SPSiteDataQuery
            SPSiteDataQuery query = new SPSiteDataQuery();
            query.Query = queryInfo.Query;
            query.Lists = queryInfo.Lists;
            if (queryInfo.RowLimit != UInt32.MaxValue)
            {
                query.RowLimit = queryInfo.RowLimit;
            }
            query.ViewFields = queryInfo.ViewFields;
            query.Webs = queryInfo.Webs;
            SiteDataResults results;

            using (SPWeb web = site.OpenWeb("/"))
            {
                //GetSiteDataResults(Microsoft.SharePoint.SPWeb,Microsoft.SharePoint.SPSiteDataQuery,System.Boolean)
                results = crossListCache.GetSiteDataResults(web, query, false);
            }
        }
    }


    // GetSiteDataResults(Microsoft.SharePoint.SPWeb,System.Boolean)
    // Returns the results of the passed in query parameter on the specified web or list. The query will be run against
    // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a web

    // This version of GetSiteDataResults forgoes the object's member SPSiteDataQuery and uses the passed in SPSiteDataQuery
    private static void ExampleFour()
    {
        using (SPSite site = new SPSite("http://adventure-works"))
        {
            //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
            ContentByQueryWebPart cbq = new ContentByQueryWebPart();
            CbqQueryVersionInfo versionInfo = cbq.BuildCbqQueryVersionInfo();
            CrossListQueryInfo queryInfo = versionInfo.VersionCrossListQueryInfo;
            // Create a new CrossListQueryCache object with the queryInfo we just got
            CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);
            SiteDataResults results;

            using (SPWeb web = site.OpenWeb("/"))
            {
                // GetSiteDataResults(Microsoft.SharePoint.SPWeb,System.Boolean)
                results = crossListCache.GetSiteDataResults(web, false);
            }
        }
    }
}

}

Remarks

This class cannot be inherited. 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.

Constructors

CrossListQueryCache(CrossListQueryInfo) CrossListQueryCache(CrossListQueryInfo) CrossListQueryCache(CrossListQueryInfo)

Creates a CrossListQueryCache object that is based on the CrossListQueryInfo class specification.

CrossListQueryCache(CrossListQueryInfo, String) CrossListQueryCache(CrossListQueryInfo, String) CrossListQueryCache(CrossListQueryInfo, String)

Creates a CrossListQueryCache object that is based on the CrossListQueryInfo class specification.

Methods

ContextUrl() ContextUrl() ContextUrl()

Gets the current URL.

GetSiteData(SPSite) GetSiteData(SPSite) GetSiteData(SPSite)

Gets the cache data that is based on the CrossListQueryInfo specification.

GetSiteData(SPWeb) GetSiteData(SPWeb) GetSiteData(SPWeb)

Gets the data from the SPWeb object.

GetSiteData(SPSite, String) GetSiteData(SPSite, String) GetSiteData(SPSite, String)

Gets the cache data from the specified site and from the specified webUrl.

GetSiteData(SPWeb, SPSiteDataQuery) GetSiteData(SPWeb, SPSiteDataQuery) GetSiteData(SPWeb, SPSiteDataQuery)

Gets the data by using the specified SPSiteDataQuery object.

GetSiteDataResults(SPSite, Boolean) GetSiteDataResults(SPSite, Boolean) GetSiteDataResults(SPSite, Boolean)

Gets the results of the current query on the specified site. The query will be run against an SPList if use SpQueryOnList is set to true. Otherwise, the query will be run against a site or Web.

GetSiteDataResults(SPWeb, Boolean) GetSiteDataResults(SPWeb, Boolean) GetSiteDataResults(SPWeb, Boolean)

Gets the results of the passed in query parameter on the specified web or list.

GetSiteDataResults(SPSite, String, Boolean) GetSiteDataResults(SPSite, String, Boolean) GetSiteDataResults(SPSite, String, Boolean)

Returns the results of the current query on the specified site.

GetSiteDataResults(SPWeb, SPSiteDataQuery, Boolean) GetSiteDataResults(SPWeb, SPSiteDataQuery, Boolean) GetSiteDataResults(SPWeb, SPSiteDataQuery, Boolean)

Gets the results of the passed-in query parameter on the specified web or list.

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to