Share via


QueryBasedCollection<T> Class

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.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public MustInherit Class QueryBasedCollection(Of T As Class) _
    Inherits CollectionBase(Of T)
'Usage
Dim instance As QueryBasedCollection(Of T)
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, 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 Windows SharePoint ServicesSPQuery 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, as well as 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, the CAML query is:

<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,' the CAML query is:

<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, as well as 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