Share via


QueryBasedCollection<T> class

Represents the collection base class that provides data paging support for large collections and querying support such as sorting and filtering.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Publishing.CollectionBase<T>
    Microsoft.SharePoint.Publishing.QueryBasedCollection<T>
      Microsoft.SharePoint.Publishing.PageLayoutCollection
      Microsoft.SharePoint.Publishing.PublishingPageCollection

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

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public MustInherit Class QueryBasedCollection(Of T As Class) _
    Inherits CollectionBase(Of T)
'Usage
Dim instance As QueryBasedCollection(Of T)
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class QueryBasedCollection<T> : CollectionBase<T>
where T : class

Type parameters

  • T

Remarks

In addition to the foreach enumeration support (For Each in Visual Basic) and Count property provided by the CollectionBase base class, this collection provides data paging support for large collections and querying support such as sorting and filtering.

You can apply sorting and filtering using Collaborative Application Markup Language (CAML), which defines a query to use in a Microsoft SharePoint FoundationSPQuery object. You must apply the CAML query when the collection is initially created or retrieved. For example, the PublishingWeb.GetPages method has overloads that take a CAML string directly, and overloads that take an SPQuery instance that has an SPQuery.Query property. You can use the CAML <OrderBy> tag to sort the collection. For example, to order a collection in ascending order based on title, use the following CAML query.

<OrderBy><FieldRef Name="Title" Ascending="TRUE"></FieldRef></OrderBy>

The CAML <Where> tag can be used for filtering the collection.

To filter a collection based on title matching some value "abc", use the following CAML query.

<Where><Eq><FieldRef Name="Title"></FieldRef><Value Type="Text">abc</Value></Eq></Where>

This collection also supports data paging, allowing subsets of the collection to be retrieved. You must specify the maximum number of objects to be retrieved in each subset when the collection is initially created or retrieved. For example, the PublishingWeb.GetPages method has overloads that take a row limit, and overloads that take an SPQuery instance that has an SPQuery.RowLimit property. The QueryNext method can be used to advance to the next subset of paged data.

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

QueryBasedCollection<T> members

Microsoft.SharePoint.Publishing namespace