Compartilhar via


ContentIterator.ItemsOfContentTypeQueryInFolder Method

Generates the query for a SPQuery object that returns all items of a specified content type inside a folder.

Namespace:  Microsoft.Office.Server.Utilities
Assembly:  Microsoft.Office.Server (in Microsoft.Office.Server.dll)

Syntax

'Declaration
Public Shared Function ItemsOfContentTypeQueryInFolder ( _
    strContentTypeName As String _
) As String
'Usage
Dim strContentTypeName As String
Dim returnValue As String

returnValue = ContentIterator.ItemsOfContentTypeQueryInFolder(strContentTypeName)
public static string ItemsOfContentTypeQueryInFolder(
    string strContentTypeName
)

Parameters

  • strContentTypeName
    Type: System.String
    The name of the content type.

Return Value

Type: System.String
The query.
Returns String.

Remarks

Must only be used for queries scoped to a folder.

For a large list, this query will be subject to throttling unless the ContentTypeId field is indexed.

The only way that this query will not be subject to throttling is if the number of items of the specified content type in the entire list are fewer than the MaxItemsPerThrottledOperation property value. As soon as the number of items of the given content type goes past that point, the query will be subject to throttling.

To ensure your query will not be subject to throttling:

  1. Ensure the ContentTypeId field is indexed, and either

  2. Query for all items in the desired folder and iterate over them, getting that match the desired content type, or

  3. Query for all items in the list of the desired content type and iterate over them, getting the items whose Folder property value is equal to the desired folder, or getting the items whose [P:Microsoft.SharePoint.SPListItem.Folder.ServerRelativeUrl.StartsWith(T:Microsoft.SharePoint.Folder.ServerRelativeUrl,T:System.StringComparison.OrdinalIgnoreCase)] property depending on whether you want to want to search recursively.

Whether you choose the second or third options depends on which query you expect to return fewer items in your specific scenario.

See Also

Reference

ContentIterator Class

ContentIterator Members

Microsoft.Office.Server.Utilities Namespace