Export (0) Print
Expand All

QueryBasedCollection<T> class

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

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

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class QueryBasedCollection<T> : CollectionBase<T>
where T : class

Type parameters

T

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.

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