Compartilhar via


CrossListQueryCache classe

Gerencia o cache da Consulta de lista de distribuição.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Publishing.CrossListQueryCache

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

Sintaxe

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

Comentários

Essa classe não pode ser herdada. Este caches de classe conjunto de dados que são retornados da consulta de lista de distribuição e aplica o público-alvo para o resultado que será retornado pela propriedade VersionCrossListQueryInfo .

Exemplos

O exemplo de código a seguir demonstra uma maneira de usar o objeto CrossListQueryCache , propriedades e métodos. Este código exibe dados no objeto CrossListQueryCache , obtém os dados e armazena os dados em um novo conteúdo por consulta Web Part para exibição.

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);
                }
            }
        }
    }
}

Segurança de thread

Os membros públicos estática (Shared no Visual Basic) desse tipo são seguros para thread. Nenhum membro de instância pode ser garantido como seguro para thread.

Ver também

Referência

CrossListQueryCache membros

Microsoft.SharePoint.Publishing namespace

ContextUrl

GetSiteData