Lombiq Helpful Libraries - Orchard Core Libraries - Dependency Injection for Orchard Core

July 17, 2022 ยท View on GitHub

Shell scope extensions

Use WithShellScopeAsync() and GetWithShellScopeAsync() to access services from another tenant. If multi-tenancy is not enabled, the default scopeName is suitable to access the Default tenant.

Usage:

var contentItem = await context.ServiceProvider.GetWithShellScopeAsync(scope =>
{
    var contentManager = scope.ServiceProvider.GetService<IContentManager>();
    return contentManager.GetAsync(contentItemId);
});