Skip to content

Commit ccbe5c5

Browse files
authored
Added link to Ipublishedcontentquery article
1 parent 306a8c6 commit ccbe5c5

File tree

1 file changed

+1
-12
lines changed
  • 15/umbraco-cms/implementation/services

1 file changed

+1
-12
lines changed

15/umbraco-cms/implementation/services/README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,8 @@ public class HandleUnPublishingHandler : INotificationHandler<ContentUnpublished
224224
```
225225

226226
#### Accessing the Published Content Cache via IPublishedContentQuery
227-
Sometimes, you may need to fetch multiple content items by ID, but `UmbracoContext.Content` only allows fetching a single content item at a time.
228227

229-
{% hint style="warning" %}
230-
In a background task, accessing the content cache using an injected `IPublishedContentQuery` or `IPublishedContentQueryAccessor` will not work, as they rely on `HttpContext`.
231-
{% endhint %}
232-
233-
Instead, use the following approach:
234-
235-
```csharp
236-
using UmbracoContextReference _ = _umbracoContextFactory.EnsureUmbracoContext();
237-
using IServiceScope serviceScope = _serviceProvider.CreateScope();
238-
IPublishedContentQuery query = serviceScope.ServiceProvider.GetRequiredService<IPublishedContentQuery>();
239-
```
228+
Sometimes, you may need to fetch multiple content items by ID, but `UmbracoContext.Content` only allows fetching a single content item at a time. For more information, see the [IPublishedContentQuery](../../reference/querying/ipublishedcontentquery.md) article.
240229

241230
#### Accessing the Published Content Cache from a Content Finder / UrlProvider
242231

0 commit comments

Comments
 (0)