Search Results for

    Show / Hide Table of Contents
    View Source

    Class PublishedContentQuery

    A class used to query for published content and media items.

    Inheritance
    object
    Namespace: Umbraco.Cms.Infrastructure
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class PublishedContentQuery : IPublishedContentQuery

    Constructors

    View Source

    PublishedContentQuery(IVariationContextAccessor, IExamineManager, IPublishedContentCache, IPublishedMediaCache)

    Declaration
    [Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 18.")]
    public PublishedContentQuery(IVariationContextAccessor variationContextAccessor, IExamineManager examineManager, IPublishedContentCache publishedContent, IPublishedMediaCache publishedMediaCache)
    Parameters
    Type Name Description
    IVariationContextAccessor variationContextAccessor
    IExamineManager examineManager
    IPublishedContentCache publishedContent
    IPublishedMediaCache publishedMediaCache
    View Source

    PublishedContentQuery(IVariationContextAccessor, IExamineManager, IPublishedContentCache, IPublishedMediaCache, IDocumentNavigationQueryService)

    Declaration
    [Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 19.")]
    public PublishedContentQuery(IVariationContextAccessor variationContextAccessor, IExamineManager examineManager, IPublishedContentCache publishedContent, IPublishedMediaCache publishedMediaCache, IDocumentNavigationQueryService documentNavigationQueryService)
    Parameters
    Type Name Description
    IVariationContextAccessor variationContextAccessor
    IExamineManager examineManager
    IPublishedContentCache publishedContent
    IPublishedMediaCache publishedMediaCache
    IDocumentNavigationQueryService documentNavigationQueryService
    View Source

    PublishedContentQuery(IVariationContextAccessor, IExamineManager, IPublishedContentCache, IPublishedMediaCache, IDocumentNavigationQueryService, IMediaNavigationQueryService)

    Initializes a new instance of the PublishedContentQuery class.

    Declaration
    public PublishedContentQuery(IVariationContextAccessor variationContextAccessor, IExamineManager examineManager, IPublishedContentCache publishedContent, IPublishedMediaCache publishedMediaCache, IDocumentNavigationQueryService documentNavigationQueryService, IMediaNavigationQueryService mediaNavigationQueryService)
    Parameters
    Type Name Description
    IVariationContextAccessor variationContextAccessor
    IExamineManager examineManager
    IPublishedContentCache publishedContent
    IPublishedMediaCache publishedMediaCache
    IDocumentNavigationQueryService documentNavigationQueryService
    IMediaNavigationQueryService mediaNavigationQueryService

    Methods

    View Source

    Content(IEnumerable<Guid>)

    Gets the published content items corresponding to the specified unique identifiers.

    Declaration
    public IEnumerable<IPublishedContent> Content(IEnumerable<Guid> ids)
    Parameters
    Type Name Description
    IEnumerable<Guid> ids

    The unique identifiers of the content items to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An enumerable of published content items matching the specified IDs.

    View Source

    Content(IEnumerable<int>)

    Gets the published content items for the specified collection of IDs.

    Declaration
    public IEnumerable<IPublishedContent> Content(IEnumerable<int> ids)
    Parameters
    Type Name Description
    IEnumerable<int> ids

    The collection of content IDs to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An enumerable of published content items matching the given IDs.

    View Source

    Content(IEnumerable<object>)

    Retrieves the published content items corresponding to the specified identifiers.

    Declaration
    public IEnumerable<IPublishedContent> Content(IEnumerable<object> ids)
    Parameters
    Type Name Description
    IEnumerable<object> ids

    A collection of identifiers for the content items to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An enumerable collection of published content items that match the provided identifiers.

    View Source

    Content(Guid)

    Gets the published content item by its unique identifier.

    Declaration
    public IPublishedContent? Content(Guid id)
    Parameters
    Type Name Description
    Guid id

    The unique identifier of the content item.

    Returns
    Type Description
    IPublishedContent

    The published content item if found; otherwise, null.

    View Source

    Content(int)

    Gets the published content item by its identifier.

    Declaration
    public IPublishedContent? Content(int id)
    Parameters
    Type Name Description
    int id

    The identifier of the content item.

    Returns
    Type Description
    IPublishedContent

    The published content item if found; otherwise, null.

    View Source

    Content(object)

    Gets the published content item with the specified identifier.

    Declaration
    public IPublishedContent? Content(object id)
    Parameters
    Type Name Description
    object id

    The identifier of the content item. Can be an int or another type convertible to an integer.

    Returns
    Type Description
    IPublishedContent

    The published content item if found; otherwise, null.

    View Source

    Content(Udi?)

    Retrieves the published content item corresponding to the specified unique document identifier (UDI).

    Declaration
    public IPublishedContent? Content(Udi? id)
    Parameters
    Type Name Description
    Udi id

    The unique document identifier (UDI) of the content item to retrieve. May be null.

    Returns
    Type Description
    IPublishedContent

    The published content item if found; otherwise, null.

    View Source

    ContentAtRoot()

    Returns the published content items located at the root of the content tree.

    Declaration
    public IEnumerable<IPublishedContent> ContentAtRoot()
    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An enumerable collection of root-level published content items.

    View Source

    Media(IEnumerable<Guid>)

    Retrieves the published media items corresponding to the specified unique identifiers.

    Declaration
    public IEnumerable<IPublishedContent> Media(IEnumerable<Guid> ids)
    Parameters
    Type Name Description
    IEnumerable<Guid> ids

    A collection of unique identifiers (GUIDs) for the media items to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An System.Collections.Generic.IEnumerable<T> containing the published media items that match the provided identifiers.

    View Source

    Media(IEnumerable<int>)

    Retrieves the media items corresponding to the specified IDs.

    Declaration
    public IEnumerable<IPublishedContent> Media(IEnumerable<int> ids)
    Parameters
    Type Name Description
    IEnumerable<int> ids

    A collection of media item IDs to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An System.Collections.Generic.IEnumerable<T> of Umbraco.Cms.Core.Models.IPublishedContent representing the found media items.

    View Source

    Media(IEnumerable<object>)

    Retrieves a collection of media items corresponding to the specified identifiers.

    Declaration
    public IEnumerable<IPublishedContent> Media(IEnumerable<object> ids)
    Parameters
    Type Name Description
    IEnumerable<object> ids

    A collection of identifiers for the media items to retrieve.

    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An System.Collections.Generic.IEnumerable<T> of Umbraco.Cms.Core.Models.IPublishedContent representing the found media items.

    View Source

    Media(Guid)

    Gets media content by its unique identifier.

    Declaration
    public IPublishedContent? Media(Guid id)
    Parameters
    Type Name Description
    Guid id

    The unique identifier of the media content.

    Returns
    Type Description
    IPublishedContent

    The media content if found; otherwise, null.

    View Source

    Media(int)

    Gets the media item with the specified identifier.

    Declaration
    public IPublishedContent? Media(int id)
    Parameters
    Type Name Description
    int id

    The identifier of the media item.

    Returns
    Type Description
    IPublishedContent

    The media item if found; otherwise, null.

    View Source

    Media(object)

    Gets a media item by its identifier.

    Declaration
    public IPublishedContent? Media(object id)
    Parameters
    Type Name Description
    object id

    The identifier of the media item.

    Returns
    Type Description
    IPublishedContent

    The media item if found; otherwise, null.

    View Source

    Media(Udi?)

    Gets a media item by its unique identifier (Udi).

    Declaration
    public IPublishedContent? Media(Udi? id)
    Parameters
    Type Name Description
    Udi id

    The unique identifier (Udi) of the media item. If null, returns null.

    Returns
    Type Description
    IPublishedContent

    The IPublishedContent representing the media item if found; otherwise, null.

    View Source

    MediaAtRoot()

    Returns all media items that are at the root level of the media library.

    Declaration
    public IEnumerable<IPublishedContent> MediaAtRoot()
    Returns
    Type Description
    IEnumerable<IPublishedContent>

    An System.Collections.Generic.IEnumerable<T> containing the root-level media items.

    View Source

    Search(IQueryExecutor)

    Executes the query and converts the results to PublishedSearchResult.

    Declaration
    public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query)
    Parameters
    Type Name Description
    IQueryExecutor query

    The query.

    Returns
    Type Description
    IEnumerable<PublishedSearchResult>

    The search results.

    View Source

    Search(IQueryExecutor, int, int, out long)

    Executes the query and converts the results to PublishedSearchResult.

    Declaration
    public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query, int skip, int take, out long totalRecords)
    Parameters
    Type Name Description
    IQueryExecutor query

    The query.

    int skip

    The amount of results to skip.

    int take

    The amount of results to take/return.

    long totalRecords

    The total amount of records.

    Returns
    Type Description
    IEnumerable<PublishedSearchResult>

    The search results.

    View Source

    Search(IQueryExecutor, int, int, out long, string?)

    Executes the query and converts the results to PublishedSearchResult.

    Declaration
    public IEnumerable<PublishedSearchResult> Search(IQueryExecutor query, int skip, int take, out long totalRecords, string? culture)
    Parameters
    Type Name Description
    IQueryExecutor query

    The query.

    int skip

    The amount of results to skip.

    int take

    The amount of results to take/return.

    long totalRecords

    The total amount of records.

    string culture

    The culture (defaults to a culture insensitive search).

    Returns
    Type Description
    IEnumerable<PublishedSearchResult>

    The search results.

    Remarks

    While enumerating results, the ambient culture is changed to be the searched culture.

    View Source

    Search(string, int, int, out long, string, string, ISet<string>?)

    Searches content.

    Declaration
    public IEnumerable<PublishedSearchResult> Search(string term, int skip, int take, out long totalRecords, string culture = "*", string indexName = "ExternalIndex", ISet<string>? loadedFields = null)
    Parameters
    Type Name Description
    string term

    The term to search.

    int skip

    The amount of results to skip.

    int take

    The amount of results to take/return.

    long totalRecords

    The total amount of records.

    string culture

    The culture (defaults to a culture insensitive search).

    string indexName

    The name of the index to search (defaults to ExternalIndexName).

    ISet<string> loadedFields

    This parameter is no longer used, because the results are loaded from the published snapshot using the single item ID field.

    Returns
    Type Description
    IEnumerable<PublishedSearchResult>

    The search results.

    Remarks

    When the culture is not specified or is *, all cultures are searched. To search for only invariant documents and fields use null. When searching on a specific culture, all culture specific fields are searched for the provided culture and all invariant fields for all documents.

    While enumerating results, the ambient culture is changed to be the searched culture.

    View Source

    Search(string, string, string)

    Searches content.

    Declaration
    public IEnumerable<PublishedSearchResult> Search(string term, string culture = "*", string indexName = "ExternalIndex")
    Parameters
    Type Name Description
    string term

    The term to search.

    string culture

    The culture (defaults to a culture insensitive search).

    string indexName

    The name of the index to search (defaults to ExternalIndexName).

    Returns
    Type Description
    IEnumerable<PublishedSearchResult>

    The search results.

    Remarks

    When the culture is not specified or is *, all cultures are searched. To search for only invariant documents and fields use null. When searching on a specific culture, all culture specific fields are searched for the provided culture and all invariant fields for all documents.

    While enumerating results, the ambient culture is changed to be the searched culture.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX