Expose IQuery<T> from ScopeProvider.

So that it can be used without requiring visibility of ISqlContext.
This commit is contained in:
Paul Johnson
2022-01-13 15:48:40 +00:00
parent 3b51850e56
commit 4a477c7378
3 changed files with 10 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
using System.Data;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Infrastructure.Persistence;
#if DEBUG_SCOPES
@@ -87,6 +88,8 @@ namespace Umbraco.Cms.Core.Scoping
/// </summary>
ISqlContext SqlContext { get; }
IQuery<T> CreateQuery<T>();
#if DEBUG_SCOPES
IEnumerable<ScopeInfo> ScopeInfos { get; }

View File

@@ -11,6 +11,7 @@ using Umbraco.Extensions;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Threading;
using Umbraco.Cms.Core.Persistence.Querying;
#if DEBUG_SCOPES
using System.Linq;
@@ -60,6 +61,8 @@ namespace Umbraco.Cms.Core.Scoping
public ISqlContext SqlContext => DatabaseFactory.SqlContext;
public IQuery<T> CreateQuery<T>() => SqlContext.Query<T>();
#region Context
private void MoveHttpContextScopeToCallContext()

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Persistence.Querying;
@@ -12,7 +12,9 @@ namespace Umbraco.Cms.Core.Services.Implement
public abstract class RepositoryService : IService
{
protected IEventMessagesFactory EventMessagesFactory { get; }
protected IScopeProvider ScopeProvider { get; }
protected ILoggerFactory LoggerFactory { get; }
protected RepositoryService(IScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory)
@@ -22,6 +24,6 @@ namespace Umbraco.Cms.Core.Services.Implement
LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
}
protected IQuery<T> Query<T>() => ScopeProvider.SqlContext.Query<T>();
protected IQuery<T> Query<T>() => ScopeProvider.CreateQuery<T>();
}
}