Table of Contents

Class ContentItemQueryBuilder

Namespace
CMS.ContentEngine
Assembly
CMS.ContentEngine.dll

A builder for content item queries. Provides a fluent API for parameterizing and retrieving items of specified content types.

public sealed class ContentItemQueryBuilder
Inheritance
object
ContentItemQueryBuilder
Extension Methods

Remarks

Use together with IContentQueryExecutor.

Constructors

ContentItemQueryBuilder()

Initializes instance of ContentItemQueryBuilder class.

public ContentItemQueryBuilder()

Methods

ForContentType(string, Action<ContentTypeQueryParameters>)

Includes content item type to executed query.

public ContentItemQueryBuilder ForContentType(string contentTypeName, Action<ContentTypeQueryParameters> configureQuery = null)

Parameters

contentTypeName string

Content item type name.

configureQuery Action<ContentTypeQueryParameters>

Function used to configure query for given contentTypeName.

Returns

ContentItemQueryBuilder

Returns this ContentItemQueryBuilder instance to chain further configuration.

Exceptions

ArgumentException

When given contentTypeName is null or empty string.

InvalidOperationException

When given contentTypeName is already included to the query or when the ForContentTypes(Action<ContentTypesQueryParameters>) method has been called previously."

ForContentTypes(Action<ContentTypesQueryParameters>)

Includes any content type determined by further configureQuery parametrization to executed query.

public ContentItemQueryBuilder ForContentTypes(Action<ContentTypesQueryParameters> configureQuery = null)

Parameters

configureQuery Action<ContentTypesQueryParameters>

Function used to configure query.

Returns

ContentItemQueryBuilder

Returns this ContentItemQueryBuilder instance to chain further configuration.

Exceptions

InvalidOperationException

When the ForContentType(string, Action<ContentTypeQueryParameters>) or ForContentTypes(Action<ContentTypesQueryParameters>) method has been called previously.

InLanguage(string, bool)

Limits the query result to language provided in languageName.

public ContentItemQueryBuilder InLanguage(string languageName, bool useLanguageFallbacks = true)

Parameters

languageName string

Content language code name of the language to limit the query to.

useLanguageFallbacks bool

Indicates if fallback languages are used when querying data. Defaults to true.

Returns

ContentItemQueryBuilder

Returns this ContentItemQueryBuilder instance to chain further configuration.

Remarks

If method is called multiple times, query result is limited to language code name from the last call.

Query result is limited only to language specified in languageName when useLanguageFallbacks is set to false.

Exceptions

ArgumentException

Thrown when the languageName is null or empty.

InWorkspaces(params string[])

Limits the query result to workspaces provided in workspaceNames.

public ContentItemQueryBuilder InWorkspaces(params string[] workspaceNames)

Parameters

workspaceNames string[]

Code names of workspaces to limit the query to.

Returns

ContentItemQueryBuilder

Returns this ContentItemQueryBuilder instance to chain further configuration.

Remarks

If method is called multiple times, query result is limited to workspace names from the last call.

Exceptions

ArgumentNullException

Thrown when the workspaceNames is null.

Parameters(Action<ContentQueryParameters>)

Modifies the outer query with specified parameters.

public ContentItemQueryBuilder Parameters(Action<ContentQueryParameters> configureQuery = null)

Parameters

configureQuery Action<ContentQueryParameters>

Function used to configure parameters of the outer query.

Returns

ContentItemQueryBuilder

Returns this ContentItemQueryBuilder instance to chain further configuration.