Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IPublishedContentQueryAccessor

    Namespace: Umbraco.Cms.Core
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public interface IPublishedContentQueryAccessor
    Remarks

    Not intended for use in background threads where you should make use of EnsureUmbracoContext() and instead resolve IPublishedContentQuery from a Microsoft.Extensions.DependencyInjection.IServiceScope e.g. using Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.CreateScope(System.IServiceProvider)

    <pre><code class="lang-csharp">// Background thread example
    using UmbracoContextReference _ = _umbracoContextFactory.EnsureUmbracoContext();
    using IServiceScope serviceScope = _serviceProvider.CreateScope();
    IPublishedContentQuery query = serviceScope.ServiceProvider.GetRequiredService<IPublishedContentQuery>();</code></pre>
    

    Methods

    View Source

    TryGetValue(out IPublishedContentQuery)

    Attempts to get the current IPublishedContentQuery instance.

    Declaration
    bool TryGetValue(out IPublishedContentQuery publishedContentQuery)
    Parameters
    Type Name Description
    IPublishedContentQuery publishedContentQuery

    When this method returns, contains the IPublishedContentQuery instance if available; otherwise, null.

    Returns
    Type Description
    bool

    true if the IPublishedContentQuery instance was retrieved successfully; otherwise, false.

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