Expose IQuery<T> from ScopeProvider.
So that it can be used without requiring visibility of ISqlContext.
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user