diff --git a/src/Umbraco.Infrastructure/Scoping/IScope.cs b/src/Umbraco.Core/Scoping/IScope.cs
similarity index 88%
rename from src/Umbraco.Infrastructure/Scoping/IScope.cs
rename to src/Umbraco.Core/Scoping/IScope.cs
index 8027e10606..312be1a35f 100644
--- a/src/Umbraco.Infrastructure/Scoping/IScope.cs
+++ b/src/Umbraco.Core/Scoping/IScope.cs
@@ -1,7 +1,6 @@
using System;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Events;
-using Umbraco.Cms.Infrastructure.Persistence;
namespace Umbraco.Cms.Core.Scoping
{
@@ -10,16 +9,6 @@ namespace Umbraco.Cms.Core.Scoping
///
public interface IScope : IDisposable, IInstanceIdentifiable
{
- ///
- /// Gets the scope database.
- ///
- IUmbracoDatabase Database { get; }
-
- ///
- /// Gets the Sql context.
- ///
- ISqlContext SqlContext { get; }
-
///
/// Gets the scope notification publisher
///
diff --git a/src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs b/src/Umbraco.Core/Scoping/IScopeProvider.cs
similarity index 97%
rename from src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs
rename to src/Umbraco.Core/Scoping/IScopeProvider.cs
index 51b7ba874a..c12680763f 100644
--- a/src/Umbraco.Infrastructure/Scoping/IScopeProvider.cs
+++ b/src/Umbraco.Core/Scoping/IScopeProvider.cs
@@ -1,7 +1,6 @@
using System.Data;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Persistence.Querying;
-using Umbraco.Cms.Infrastructure.Persistence;
#if DEBUG_SCOPES
using System.Collections.Generic;
@@ -84,10 +83,8 @@ namespace Umbraco.Cms.Core.Scoping
IScopeContext Context { get; }
///
- /// Gets the sql context.
+ /// Creates an instance of
///
- ISqlContext SqlContext { get; }
-
IQuery CreateQuery();
#if DEBUG_SCOPES
diff --git a/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs b/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
index ef7255a0d6..b8fc8d68a5 100644
--- a/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
+++ b/src/Umbraco.Infrastructure/Cache/DefaultRepositoryCachePolicy.cs
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Cache
diff --git a/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs b/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
index a04cd69900..6b2be94d45 100644
--- a/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
+++ b/src/Umbraco.Infrastructure/Cache/FullDataSetRepositoryCachePolicy.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
@@ -7,6 +7,7 @@ using System.Linq;
using Umbraco.Cms.Core.Collections;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.Cache
diff --git a/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs b/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
index 8913de956b..6124d9fb7a 100644
--- a/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
+++ b/src/Umbraco.Infrastructure/Cache/RepositoryCachePolicyBase.cs
@@ -1,10 +1,11 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Core.Cache
{
diff --git a/src/Umbraco.Infrastructure/Cache/SingleItemsOnlyRepositoryCachePolicy.cs b/src/Umbraco.Infrastructure/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
index 5b1420be65..f74d602bb8 100644
--- a/src/Umbraco.Infrastructure/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
+++ b/src/Umbraco.Infrastructure/Cache/SingleItemsOnlyRepositoryCachePolicy.cs
@@ -1,8 +1,9 @@
-// Copyright (c) Umbraco.
+// Copyright (c) Umbraco.
// See LICENSE for more details.
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Core.Cache
{
diff --git a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs
index b979ce239d..5a4faa6c43 100644
--- a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs
+++ b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs
@@ -50,6 +50,7 @@ using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_0_0.DataTypes;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Mappers;
using Umbraco.Cms.Infrastructure.Runtime;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Infrastructure.Search;
using Umbraco.Cms.Infrastructure.Serialization;
using Umbraco.Extensions;
@@ -92,9 +93,11 @@ namespace Umbraco.Cms.Infrastructure.DependencyInjection
builder.Mappers().AddCoreMappers();
// register the scope provider
- builder.Services.AddSingleton(); // implements both IScopeProvider and IScopeAccessor
+ builder.Services.AddSingleton(); // implements IScopeProvider, IScopeAccessor
builder.Services.AddSingleton(f => f.GetRequiredService());
builder.Services.AddSingleton(f => f.GetRequiredService());
+
+
builder.Services.AddScoped();
builder.Services.AddSingleton();
diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
index 78dbdddc84..0aa2cdda57 100644
--- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
@@ -10,6 +10,7 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Migrations.Upgrade;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Migrations.Install
@@ -21,6 +22,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
{
private readonly IUmbracoDatabaseFactory _databaseFactory;
private readonly IScopeProvider _scopeProvider;
+ private readonly IScopeAccessor _scopeAccessor;
private readonly IRuntimeState _runtimeState;
private readonly IKeyValueService _keyValueService;
private readonly ILogger _logger;
@@ -38,6 +40,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
///
public DatabaseBuilder(
IScopeProvider scopeProvider,
+ IScopeAccessor scopeAccessor,
IUmbracoDatabaseFactory databaseFactory,
IRuntimeState runtimeState,
ILoggerFactory loggerFactory,
@@ -50,6 +53,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory)
{
_scopeProvider = scopeProvider;
+ _scopeAccessor = scopeAccessor;
_databaseFactory = databaseFactory;
_runtimeState = runtimeState;
_logger = loggerFactory.CreateLogger();
@@ -113,17 +117,17 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
using (var scope = _scopeProvider.CreateScope())
{
// look for the super user with default password
- var sql = scope.Database.SqlContext.Sql()
+ var sql = _scopeAccessor.AmbientScope.Database.SqlContext.Sql()
.SelectCount()
.From()
.Where(x => x.Id == Constants.Security.SuperUserId && x.Password == "default");
- var result = scope.Database.ExecuteScalar(sql);
+ var result = _scopeAccessor.AmbientScope.Database.ExecuteScalar(sql);
var has = result != 1;
if (has == false)
{
// found only 1 user == the default user with default password
// however this always exists on uCloud, also need to check if there are other users too
- result = scope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUser");
+ result = _scopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoUser");
has = result != 1;
}
scope.Complete();
@@ -135,7 +139,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
{
using (var scope = _scopeProvider.CreateScope(autoComplete: true))
{
- return scope.Database.IsUmbracoInstalled();
+ return _scopeAccessor.AmbientScope.Database.IsUmbracoInstalled();
}
}
@@ -336,7 +340,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
if (_databaseSchemaValidationResult != null)
return _databaseSchemaValidationResult;
- _databaseSchemaValidationResult = scope.Database.ValidateSchema();
+ _databaseSchemaValidationResult = _scopeAccessor.AmbientScope.Database.ValidateSchema();
scope.Complete();
@@ -372,7 +376,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
_logger.LogInformation("Database configuration status: Started");
- var database = scope.Database;
+ var database = _scopeAccessor.AmbientScope.Database;
var message = string.Empty;
diff --git a/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs b/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
index 09cddbc20b..358d7d0281 100644
--- a/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
+++ b/src/Umbraco.Infrastructure/Migrations/MigrationPlanExecutor.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Migrations;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using Type = System.Type;
@@ -12,16 +13,19 @@ namespace Umbraco.Cms.Infrastructure.Migrations
public class MigrationPlanExecutor : IMigrationPlanExecutor
{
private readonly IScopeProvider _scopeProvider;
+ private readonly IScopeAccessor _scopeAccessor;
private readonly ILoggerFactory _loggerFactory;
private readonly IMigrationBuilder _migrationBuilder;
private readonly ILogger _logger;
public MigrationPlanExecutor(
IScopeProvider scopeProvider,
+ IScopeAccessor scopeAccessor,
ILoggerFactory loggerFactory,
IMigrationBuilder migrationBuilder)
{
_scopeProvider = scopeProvider;
+ _scopeAccessor = scopeAccessor;
_loggerFactory = loggerFactory;
_migrationBuilder = migrationBuilder;
_logger = _loggerFactory.CreateLogger();
@@ -61,7 +65,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations
// that packages notification handlers may explode because that package isn't fully installed yet.
using (scope.Notifications.Suppress())
{
- var context = new MigrationContext(plan, scope.Database, _loggerFactory.CreateLogger());
+ var context = new MigrationContext(plan, _scopeAccessor.AmbientScope.Database, _loggerFactory.CreateLogger());
while (transition != null)
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditEntryRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditEntryRepository.cs
index e3685dd32c..9cadc82e49 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditEntryRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditEntryRepository.cs
@@ -12,6 +12,7 @@ using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
index d528f69dce..644dc4bc26 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/AuditRepository.cs
@@ -8,9 +8,9 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/CacheInstructionRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/CacheInstructionRepository.cs
index d0e025e06e..3ce9aad530 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/CacheInstructionRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/CacheInstructionRepository.cs
@@ -4,9 +4,9 @@ using System.Linq;
using NPoco;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
@@ -21,7 +21,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
public CacheInstructionRepository(IScopeAccessor scopeAccessor) => _scopeAccessor = scopeAccessor;
///
- private IScope AmbientScope => _scopeAccessor.AmbientScope;
+ private IDatabaseScope AmbientScope => _scopeAccessor.AmbientScope;
///
public int CountAll()
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ConsentRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ConsentRepository.cs
index 87a112fe08..194369285b 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ConsentRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ConsentRepository.cs
@@ -6,10 +6,10 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs
index fd4d1c33b9..0b4af6bdee 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentRepositoryBase.cs
@@ -15,12 +15,12 @@ using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.PropertyEditors;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
index 04ca55b499..66ab87b743 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeCommonRepository.cs
@@ -12,6 +12,7 @@ using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using Enumerable = System.Linq.Enumerable;
@@ -42,7 +43,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
_shortStringHelper = shortStringHelper;
}
- private IScope AmbientScope => _scopeAccessor.AmbientScope;
+ private IDatabaseScope AmbientScope => _scopeAccessor.AmbientScope;
private IUmbracoDatabase Database => AmbientScope.Database;
private ISqlContext SqlContext => AmbientScope.SqlContext;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs
index 9b0fe45c79..56fd356011 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs
@@ -8,11 +8,11 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
index 38e8a99d08..5ffdf4bf10 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepositoryBase.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
@@ -12,12 +12,12 @@ using Umbraco.Cms.Core.Exceptions;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeContainerRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
index 6128b2e9b2..f8fc9e14be 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeContainerRepository.cs
@@ -1,7 +1,7 @@
-using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeRepository.cs
index f70048c4f9..954d3e0d0f 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DataTypeRepository.cs
@@ -13,12 +13,12 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.PropertyEditors;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DictionaryRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DictionaryRepository.cs
index bc9892b1ee..98b1820204 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DictionaryRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DictionaryRepository.cs
@@ -9,10 +9,10 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
index 79663c292e..f97aec0917 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentBlueprintRepository.cs
@@ -4,9 +4,9 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.PropertyEditors;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
index 41645dba27..0d77f3d53b 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs
@@ -21,6 +21,7 @@ using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentTypeContainerRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentTypeContainerRepository.cs
index c6c0df848c..f37886fee2 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentTypeContainerRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentTypeContainerRepository.cs
@@ -1,7 +1,7 @@
-using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
index 21bd883c68..52b73bed26 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentVersionRepository.cs
@@ -7,6 +7,7 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DomainRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DomainRepository.cs
index d7fd2e9c7c..7633264ed6 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DomainRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DomainRepository.cs
@@ -11,6 +11,7 @@ using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityContainerRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityContainerRepository.cs
index b30c5ae1a4..37cbf979e2 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityContainerRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityContainerRepository.cs
@@ -8,8 +8,8 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepository.cs
index 83cb31774d..82cc897e45 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepository.cs
@@ -8,11 +8,11 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepositoryBase.cs
index 79e6f732a2..3518803490 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepositoryBase.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/EntityRepositoryBase.cs
@@ -10,6 +10,7 @@ using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs
index 814bfefc88..60fa5e02e7 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs
@@ -9,11 +9,11 @@ using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/KeyValueRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/KeyValueRepository.cs
index 288f480ed1..653e916be6 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/KeyValueRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/KeyValueRepository.cs
@@ -7,9 +7,9 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LanguageRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LanguageRepository.cs
index d0aee52406..fc40343692 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LanguageRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LanguageRepository.cs
@@ -10,10 +10,10 @@ using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LogViewerQueryRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LogViewerQueryRepository.cs
index 556aba8e22..3482da377d 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LogViewerQueryRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LogViewerQueryRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
@@ -8,8 +8,8 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs
index 535895e8ed..c0ba8f3ac4 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MacroRepository.cs
@@ -9,11 +9,11 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs
index 29960a4044..a431fb6896 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaRepository.cs
@@ -12,12 +12,12 @@ using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.PropertyEditors;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeContainerRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeContainerRepository.cs
index 7710f3efb1..069b49de2f 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeContainerRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeContainerRepository.cs
@@ -1,7 +1,7 @@
-using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeRepository.cs
index 26d24cbac0..0a07fb2260 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MediaTypeRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
@@ -8,10 +8,10 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs
index 970e498b26..89858951d7 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs
@@ -9,10 +9,10 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
index a1b15f407d..db45c40007 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberRepository.cs
@@ -21,6 +21,7 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberTypeRepository.cs
index ca3edea81c..27e51551e2 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberTypeRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberTypeRepository.cs
@@ -8,11 +8,11 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/NotificationsRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/NotificationsRepository.cs
index 2d68c95fe2..c35052b9d1 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/NotificationsRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/NotificationsRepository.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core.Models;
@@ -7,6 +7,7 @@ using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
@@ -20,7 +21,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
_scopeAccessor = scopeAccessor;
}
- private IScope AmbientScope => _scopeAccessor.AmbientScope;
+ private IDatabaseScope AmbientScope => _scopeAccessor.AmbientScope;
public IEnumerable GetUsersNotifications(IEnumerable userIds, string action, IEnumerable nodeIds, Guid objectType)
{
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PermissionRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PermissionRepository.cs
index 2b38d55212..afcefdee2c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PermissionRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PermissionRepository.cs
@@ -9,8 +9,8 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PublicAccessRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PublicAccessRepository.cs
index 1c4dcdb675..dbddb56b68 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PublicAccessRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PublicAccessRepository.cs
@@ -8,10 +8,10 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RedirectUrlRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RedirectUrlRepository.cs
index 6ab29aa47e..5a15cc5b3d 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RedirectUrlRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RedirectUrlRepository.cs
@@ -9,8 +9,8 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs
index 749fc9d77b..63d49f06af 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs
@@ -9,12 +9,12 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationTypeRepository.cs
index 151d08a2ff..f50e307cfa 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationTypeRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationTypeRepository.cs
@@ -9,10 +9,10 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RepositoryBase.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RepositoryBase.cs
index 6e550f9362..4f82603710 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RepositoryBase.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RepositoryBase.cs
@@ -3,8 +3,8 @@ using NPoco;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Persistence;
using Umbraco.Cms.Core.Persistence.Querying;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
@@ -35,11 +35,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
///
/// Gets the AmbientScope
///
- protected IScope AmbientScope
+ protected IDatabaseScope AmbientScope
{
get
{
- IScope scope = ScopeAccessor.AmbientScope;
+ IDatabaseScope scope = ScopeAccessor.AmbientScope;
if (scope == null)
{
throw new InvalidOperationException("Cannot run a repository without an ambient scope.");
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ServerRegistrationRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
index 98aef6fa6d..4d1ef3fa88 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ServerRegistrationRepository.cs
@@ -10,6 +10,7 @@ using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/SimpleGetRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/SimpleGetRepository.cs
index 6053d35085..2b7257ff8e 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/SimpleGetRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/SimpleGetRepository.cs
@@ -6,8 +6,8 @@ using NPoco;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TagRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TagRepository.cs
index 919bbeea31..81e6a82f89 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TagRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TagRepository.cs
@@ -9,10 +9,10 @@ using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TemplateRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TemplateRepository.cs
index 6d2c02484a..f318d4d31e 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TemplateRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TemplateRepository.cs
@@ -12,11 +12,11 @@ using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserGroupRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserGroupRepository.cs
index d6be3cf730..b27f42858a 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserGroupRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserGroupRepository.cs
@@ -10,11 +10,11 @@ using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
index b94daf5d83..26d37ed80a 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
@@ -13,13 +13,13 @@ using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Models.Membership;
using Umbraco.Cms.Core.Persistence.Querying;
using Umbraco.Cms.Core.Persistence.Repositories;
-using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Factories;
using Umbraco.Cms.Infrastructure.Persistence.Mappers;
using Umbraco.Cms.Infrastructure.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
diff --git a/src/Umbraco.Infrastructure/Scoping/IDatabaseScope.cs b/src/Umbraco.Infrastructure/Scoping/IDatabaseScope.cs
new file mode 100644
index 0000000000..aac5f48b4b
--- /dev/null
+++ b/src/Umbraco.Infrastructure/Scoping/IDatabaseScope.cs
@@ -0,0 +1,18 @@
+using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Persistence;
+
+namespace Umbraco.Cms.Infrastructure.Scoping
+{
+ public interface IDatabaseScope : IScope
+ {
+ ///
+ /// Gets the scope database.
+ ///
+ IUmbracoDatabase Database { get; }
+
+ ///
+ /// Gets the Sql context.
+ ///
+ ISqlContext SqlContext { get; }
+ }
+}
diff --git a/src/Umbraco.Infrastructure/Scoping/IScopeAccessor.cs b/src/Umbraco.Infrastructure/Scoping/IScopeAccessor.cs
index a699a8bc3e..234ee0232b 100644
--- a/src/Umbraco.Infrastructure/Scoping/IScopeAccessor.cs
+++ b/src/Umbraco.Infrastructure/Scoping/IScopeAccessor.cs
@@ -1,17 +1,11 @@
-// Copyright (c) Umbraco.
-// See LICENSE for more details.
-
-namespace Umbraco.Cms.Core.Scoping
+namespace Umbraco.Cms.Infrastructure.Scoping
{
- ///
- /// Provides access to the ambient scope.
- ///
public interface IScopeAccessor
{
///
/// Gets the ambient scope.
///
/// Returns null if there is no ambient scope.
- IScope AmbientScope { get; }
+ IDatabaseScope AmbientScope { get; }
}
}
diff --git a/src/Umbraco.Infrastructure/Scoping/Scope.cs b/src/Umbraco.Infrastructure/Scoping/Scope.cs
index e0f947b4aa..1c1bd636b9 100644
--- a/src/Umbraco.Infrastructure/Scoping/Scope.cs
+++ b/src/Umbraco.Infrastructure/Scoping/Scope.cs
@@ -10,6 +10,7 @@ using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Infrastructure.Persistence;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Core.Collections;
using Umbraco.Extensions;
@@ -19,7 +20,7 @@ namespace Umbraco.Cms.Core.Scoping
/// Implements .
///
/// Not thread-safe obviously.
- internal class Scope : IScope
+ internal class Scope : IDatabaseScope
{
private readonly bool _autoComplete;
private readonly CoreDebugSettings _coreDebugSettings;
diff --git a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs
index 944c547236..0f5fba4d4a 100644
--- a/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs
+++ b/src/Umbraco.Infrastructure/Scoping/ScopeProvider.cs
@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Threading;
using Umbraco.Cms.Core.Persistence.Querying;
+using Umbraco.Cms.Infrastructure.Scoping;
#if DEBUG_SCOPES
using System.Linq;
@@ -286,10 +287,10 @@ namespace Umbraco.Cms.Core.Scoping
#region Ambient Scope
- IScope IScopeAccessor.AmbientScope => AmbientScope;
+ IDatabaseScope IScopeAccessor.AmbientScope => AmbientScope;
///
- /// Get or set the Ambient (Current) for the current execution context.
+ /// Gets or set the Ambient (Current) for the current execution context.
///
///
/// The current execution context may be request based (HttpContext) or on a background thread (AsyncLocal)
diff --git a/src/Umbraco.Infrastructure/Services/IdKeyMap.cs b/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
index 49747534c6..cc461cead7 100644
--- a/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
+++ b/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
@@ -1,23 +1,26 @@
-using System;
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Scoping;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Cms.Core.Services
{
public class IdKeyMap : IIdKeyMap,IDisposable
{
private readonly IScopeProvider _scopeProvider;
+ private readonly IScopeAccessor _scopeAccessor;
private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim();
private readonly Dictionary> _id2Key = new Dictionary>();
private readonly Dictionary> _key2Id = new Dictionary>();
- public IdKeyMap(IScopeProvider scopeProvider)
+ public IdKeyMap(IScopeProvider scopeProvider, IScopeAccessor scopeAccessor)
{
_scopeProvider = scopeProvider;
+ _scopeAccessor = scopeAccessor;
}
// note - for pure read-only we might want to *not* enforce a transaction?
@@ -170,11 +173,11 @@ namespace Umbraco.Cms.Core.Services
//if it's unknown don't include the nodeObjectType in the query
if (umbracoObjectType == UmbracoObjectTypes.Unknown)
{
- val = scope.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id", new { id = key});
+ val = _scopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id", new { id = key});
}
else
{
- val = scope.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
+ val = _scopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT id FROM umbracoNode WHERE uniqueId=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
new { id = key, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Cms.Core.Constants.ObjectTypes.IdReservation });
}
scope.Complete();
@@ -258,11 +261,11 @@ namespace Umbraco.Cms.Core.Services
//if it's unknown don't include the nodeObjectType in the query
if (umbracoObjectType == UmbracoObjectTypes.Unknown)
{
- val = scope.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id", new { id });
+ val = _scopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id", new { id });
}
else
{
- val = scope.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
+ val = _scopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT uniqueId FROM umbracoNode WHERE id=@id AND (nodeObjectType=@type OR nodeObjectType=@reservation)",
new { id, type = GetNodeObjectTypeGuid(umbracoObjectType), reservation = Cms.Core.Constants.ObjectTypes.IdReservation });
}
scope.Complete();
diff --git a/src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs
index c52c1271ad..60face6428 100644
--- a/src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs
+++ b/src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs
@@ -13,6 +13,7 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.PublishedCache;
using Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
using Umbraco.Cms.Infrastructure.PublishedCache.Persistence;
+using Umbraco.Cms.Infrastructure.Scoping;
namespace Umbraco.Extensions
{
@@ -42,7 +43,7 @@ namespace Umbraco.Extensions
// TODO: Gotta wonder how much this does actually improve perf? It's a lot of weird code to make this happen so hope it's worth it
builder.Services.AddUnique(factory =>
{
- var idkSvc = new IdKeyMap(factory.GetRequiredService());
+ var idkSvc = new IdKeyMap(factory.GetRequiredService(), factory.GetRequiredService());
if (factory.GetRequiredService() is PublishedSnapshotService publishedSnapshotService)
{
idkSvc.SetMapper(UmbracoObjectTypes.Document, id => publishedSnapshotService.GetDocumentUid(id), uid => publishedSnapshotService.GetDocumentId(uid));
diff --git a/src/Umbraco.PublishedCache.NuCache/Persistence/NuCacheContentRepository.cs b/src/Umbraco.PublishedCache.NuCache/Persistence/NuCacheContentRepository.cs
index 649bc0eebb..8aa35c1608 100644
--- a/src/Umbraco.PublishedCache.NuCache/Persistence/NuCacheContentRepository.cs
+++ b/src/Umbraco.PublishedCache.NuCache/Persistence/NuCacheContentRepository.cs
@@ -18,6 +18,7 @@ using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
using Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Persistence.SqlExtensionsStatics;
using Constants = Umbraco.Cms.Core.Constants;
@@ -694,7 +695,7 @@ AND cmsContentNu.nodeId IS NULL
}
}
- public ContentNodeKit GetMediaSource(IScope scope, int id)
+ public ContentNodeKit GetMediaSource(IDatabaseScope scope, int id)
{
var sql = SqlMediaSourcesSelect()
.Append(SqlObjectTypeNotTrashed(SqlContext, Constants.ObjectTypes.Media))
diff --git a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
index 314a614b49..25f6194fde 100644
--- a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
+++ b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
@@ -31,6 +31,7 @@ using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Infrastructure.DependencyInjection;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Mappers;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.DependencyInjection;
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
index 40dbad176e..19d4080524 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs
@@ -56,7 +56,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Migrations
upgrader.Execute(MigrationPlanExecutor, ScopeProvider, Mock.Of());
- var helper = new DatabaseSchemaCreator(scope.Database, LoggerFactory.CreateLogger(), LoggerFactory, UmbracoVersion, EventAggregator);
+ var helper = new DatabaseSchemaCreator(ScopeAccessor.AmbientScope.Database, LoggerFactory.CreateLogger(), LoggerFactory, UmbracoVersion, EventAggregator);
bool exists = helper.TableExists("umbracoUser");
Assert.IsTrue(exists);
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs
index ef6585bef6..3feac1ce38 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs
@@ -150,7 +150,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
using IScope scope = ScopeProvider.CreateScope();
foreach (IPropertyType propertyType in mRBasePage.PropertyTypes)
{
- PropertyTypeDto propertyTypeDto = scope.Database.First("WHERE id = @id", new { id = propertyType.Id });
+ PropertyTypeDto propertyTypeDto = ScopeAccessor.AmbientScope.Database.First("WHERE id = @id", new { id = propertyType.Id });
Assert.AreEqual(propertyTypeDto.UniqueId, propertyType.Key);
}
}
@@ -424,7 +424,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
string configuration;
using (IScope scope = ScopeProvider.CreateScope())
{
- List dtos = scope.Database.Fetch("WHERE nodeId = @Id", new { dataTypeDefinitions.First().Id });
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch("WHERE nodeId = @Id", new { dataTypeDefinitions.First().Id });
configuration = dtos.Single().Configuration;
}
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs
index 96ded92f41..fa539ef1e8 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/LocksTests.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
// create a few lock objects
using (var scope = ScopeProvider.CreateScope())
{
- var database = scope.Database;
+ var database = ScopeAccessor.AmbientScope.Database;
database.Insert("umbracoLock", "id", false, new LockDto { Id = 1, Name = "Lock.1" });
database.Insert("umbracoLock", "id", false, new LockDto { Id = 2, Name = "Lock.2" });
database.Insert("umbracoLock", "id", false, new LockDto { Id = 3, Name = "Lock.3" });
@@ -121,7 +121,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
using (var scope = ScopeProvider.CreateScope())
{
- var db = scope.Database;
+ var db = ScopeAccessor.AmbientScope.Database;
try
{
db.EnableSqlCount = true;
@@ -297,7 +297,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
Console.WriteLine($"[{id1}] WAIT {id1}");
scope.EagerWriteLock(id1);
Console.WriteLine($"[{id1}] GRANT {id1}");
- WriteLocks(scope.Database);
+ WriteLocks(ScopeAccessor.AmbientScope.Database);
myEv.Set();
if (id1 == 1)
@@ -312,7 +312,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
Console.WriteLine($"[{id1}] WAIT {id2}");
scope.EagerWriteLock(id2);
Console.WriteLine($"[{id1}] GRANT {id2}");
- WriteLocks(scope.Database);
+ WriteLocks(ScopeAccessor.AmbientScope.Database);
}
catch (Exception e)
{
@@ -483,7 +483,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
{
using (var scope = ScopeProvider.CreateScope())
{
- var realDb = (Database)scope.Database;
+ var realDb = (Database)ScopeAccessor.AmbientScope.Database;
realDb.CommandTimeout = 1000;
Console.WriteLine("Write lock A");
@@ -505,7 +505,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
Console.WriteLine($"[{id}] WAIT {id}");
scope.EagerWriteLock(id);
Console.WriteLine($"[{id}] GRANT {id}");
- WriteLocks(scope.Database);
+ WriteLocks(ScopeAccessor.AmbientScope.Database);
myEv.Set();
otherEv.WaitOne();
}
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoBulkInsertTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoBulkInsertTests.cs
index 7fd90c97b3..10b0a06032 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoBulkInsertTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoBulkInsertTests.cs
@@ -39,7 +39,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
using (IScope scope = ScopeProvider.CreateScope())
{
// Still no what we want, but look above.
- IUmbracoDatabase dbSqlServer = scope.Database;
+ IUmbracoDatabase dbSqlServer = ScopeAccessor.AmbientScope.Database;
// drop the table
dbSqlServer.Execute("DROP TABLE [umbracoServer]");
@@ -103,7 +103,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
{
using (IScope scope = ScopeProvider.CreateScope())
{
- scope.Database.BulkInsertRecords(servers);
+ ScopeAccessor.AmbientScope.Database.BulkInsertRecords(servers);
scope.Complete();
}
}
@@ -111,7 +111,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// Assert
using (IScope scope = ScopeProvider.CreateScope())
{
- Assert.That(scope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(1000));
+ Assert.That(ScopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(1000));
}
}
@@ -136,7 +136,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
{
using (IScope scope = ScopeProvider.CreateScope())
{
- scope.Database.BulkInsertRecords(servers);
+ ScopeAccessor.AmbientScope.Database.BulkInsertRecords(servers);
// Don't call complete here - the transaction will be rolled back.
}
@@ -145,7 +145,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// Assert
using (IScope scope = ScopeProvider.CreateScope())
{
- Assert.That(scope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(0));
+ Assert.That(ScopeAccessor.AmbientScope.Database.ExecuteScalar("SELECT COUNT(*) FROM umbracoServer"), Is.EqualTo(0));
}
}
@@ -168,7 +168,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
IDbCommand[] commands;
using (IScope scope = ScopeProvider.CreateScope())
{
- commands = scope.Database.GenerateBulkInsertCommands(servers.ToArray());
+ commands = ScopeAccessor.AmbientScope.Database.GenerateBulkInsertCommands(servers.ToArray());
scope.Complete();
}
@@ -198,7 +198,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
IDbCommand[] commands;
using (IScope scope = ScopeProvider.CreateScope())
{
- commands = scope.Database.GenerateBulkInsertCommands(servers.ToArray());
+ commands = ScopeAccessor.AmbientScope.Database.GenerateBulkInsertCommands(servers.ToArray());
scope.Complete();
}
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoFetchTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoFetchTests.cs
index bea5a8fb8c..19976da976 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoFetchTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoFetchTests.cs
@@ -23,7 +23,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
{
using (IScope scope = ScopeProvider.CreateScope())
{
- InsertData(scope.Database);
+ InsertData(ScopeAccessor.AmbientScope.Database);
scope.Complete();
}
}
@@ -166,11 +166,11 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// var sql = @"
// SELECT zbThing1.id, zbThing1.name
// FROM zbThing1";
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select()
.From();
- List dtos = scope.Database.Fetch(sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch(sql);
Assert.AreEqual(2, dtos.Count);
Assert.AreEqual("one", dtos.First(x => x.Id == 1).Name);
}
@@ -189,12 +189,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// zbThing1.id Thing__id, zbThing1.name Thing__name
// FROM zbThing2
// JOIN zbThing1 ON zbThing2.thingId=zbThing1.id";
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select(r => r.Select(x => x.Thing))
.From()
.InnerJoin().On((t2, t1) => t2.ThingId == t1.Id);
- List dtos = scope.Database.Fetch(sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch(sql);
Assert.AreEqual(3, dtos.Count);
Assert.AreEqual("uno", dtos.First(x => x.Id == 1).Name);
Assert.IsNotNull(dtos.First(x => x.Id == 1).Thing);
@@ -218,14 +218,14 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// FROM zbThing1
// JOIN zbThing2 ON zbThing1.id=zbThing2.thingId
// WHERE zbThing1.id=1");
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select(r => r.Select(x => x.Things))
.From()
.InnerJoin().On(left => left.Id, right => right.ThingId)
.Where(x => x.Id == 1);
// var dtos = scope.Database.FetchOneToMany(x => x.Things, x => x.Id, sql);
- List dtos = scope.Database.FetchOneToMany(x => x.Things, sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.FetchOneToMany(x => x.Things, sql);
Assert.AreEqual(1, dtos.Count);
Thing3Dto dto1 = dtos.FirstOrDefault(x => x.Id == 1);
@@ -258,13 +258,13 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// FROM zbThing1
// JOIN zbThing2 ON zbThing1.id=zbThing2.thingId
// ORDER BY zbThing1.id";
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select(r => r.Select(x => x.Things)) // select Thing3Dto, and Thing2Dto for Things
.From()
.InnerJoin().On(left => left.Id, right => right.ThingId)
.OrderBy(x => x.Id);
- List dtos = scope.Database.FetchOneToMany(x => x.Things, /*x => x.Id,*/ sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.FetchOneToMany(x => x.Things, /*x => x.Id,*/ sql);
Assert.AreEqual(2, dtos.Count);
Thing3Dto dto1 = dtos.FirstOrDefault(x => x.Id == 1);
@@ -283,18 +283,18 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
{
using (IScope scope = ScopeProvider.CreateScope())
{
- scope.SqlContext.Templates.Clear();
+ ScopeAccessor.AmbientScope.SqlContext.Templates.Clear();
- Sql sql = scope.SqlContext.Templates.Get("xxx", s => s
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Templates.Get("xxx", s => s
.Select(r => r.Select(x => x.Things)) // select Thing3Dto, and Thing2Dto for Things
.From()
.InnerJoin().On(left => left.Id, right => right.ThingId)
.OrderBy(x => x.Id)).Sql();
// cached
- sql = scope.SqlContext.Templates.Get("xxx", s => throw new InvalidOperationException()).Sql();
+ sql = ScopeAccessor.AmbientScope.SqlContext.Templates.Get("xxx", s => throw new InvalidOperationException()).Sql();
- List dtos = scope.Database.FetchOneToMany(x => x.Things, /*x => x.Id,*/ sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.FetchOneToMany(x => x.Things, /*x => x.Id,*/ sql);
Assert.AreEqual(2, dtos.Count);
Thing3Dto dto1 = dtos.FirstOrDefault(x => x.Id == 1);
@@ -326,14 +326,14 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// JOIN zbThing2Group ON zbThing1.id=zbThing2Group.thingId
// JOIN zbThingGroup ON zbThing2Group.groupId=zbThingGroup.id
// ORDER BY zbThing1.id";
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select(r => r.Select(x => x.Groups))
.From()
.InnerJoin().On((t, t2g) => t.Id == t2g.ThingId)
.InnerJoin().On((t2g, tg) => t2g.GroupId == tg.Id)
.OrderBy(x => x.Id);
- List dtos = scope.Database.FetchOneToMany(x => x.Groups, /*x => x.Id,*/ sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.FetchOneToMany(x => x.Groups, /*x => x.Id,*/ sql);
Assert.AreEqual(2, dtos.Count);
Thing4Dto dto1 = dtos.FirstOrDefault(x => x.Id == 1);
@@ -360,14 +360,14 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
// FROM zbThing1
// JOIN zbThing2Group ON zbThing1.id=zbThing2Group.thingId
// GROUP BY zbThing1.id, zbThing1.name";
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.Select()
.Append(", COUNT(zbThing2Group.groupId) AS groupCount") // FIXME:
.From()
.InnerJoin().On((t, t2g) => t.Id == t2g.ThingId)
.GroupBy(x => x.Id, x => x.Name);
- List dtos = scope.Database.Fetch(sql);
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch(sql);
Assert.AreEqual(2, dtos.Count);
Thing5Dto dto1 = dtos.FirstOrDefault(x => x.Id == 1);
@@ -390,12 +390,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
{
using (IScope scope = ScopeProvider.CreateScope())
{
- Sql sql = scope.SqlContext.Sql()
+ Sql sql = ScopeAccessor.AmbientScope.SqlContext.Sql()
.SelectAll()
.From()
.Where(x => x.Id == 1);
- Thing1Dto dto = scope.Database.Fetch(sql).FirstOrDefault();
+ Thing1Dto dto = ScopeAccessor.AmbientScope.Database.Fetch(sql).FirstOrDefault();
Assert.IsNotNull(dto);
Assert.AreEqual("one", dto.Name);
@@ -406,7 +406,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
//// Assert.AreEqual("one", dto.Name);
var sql3 = new Sql(sql.SQL, 1);
- dto = scope.Database.Fetch(sql3).FirstOrDefault();
+ dto = ScopeAccessor.AmbientScope.Database.Fetch(sql3).FirstOrDefault();
Assert.IsNotNull(dto);
Assert.AreEqual("one", dto.Name);
}
@@ -418,28 +418,28 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPoco
using (IScope scope = ScopeProvider.CreateScope())
{
var tA1A = new ThingA1Dto { Id = 1, Name = "a1_a" };
- scope.Database.Insert(tA1A);
+ ScopeAccessor.AmbientScope.Database.Insert(tA1A);
var tA1B = new ThingA1Dto { Id = 2, Name = "a1_b" };
- scope.Database.Insert(tA1B);
+ ScopeAccessor.AmbientScope.Database.Insert(tA1B);
var tA1C = new ThingA1Dto { Id = 3, Name = "a1_c" };
- scope.Database.Insert(tA1C);
+ ScopeAccessor.AmbientScope.Database.Insert(tA1C);
var tA2A = new ThingA2Dto { Id = 1, Name = "a2_a" };
- scope.Database.Insert(tA2A);
+ ScopeAccessor.AmbientScope.Database.Insert(tA2A);
var tA2B = new ThingA2Dto { Id = 2, Name = "a2_b" };
- scope.Database.Insert(tA2B);
+ ScopeAccessor.AmbientScope.Database.Insert(tA2B);
var tA2C = new ThingA2Dto { Id = 3, Name = "a2_c" };
- scope.Database.Insert(tA2C);
+ ScopeAccessor.AmbientScope.Database.Insert(tA2C);
var tA3A = new ThingA3Dto { Id = 1, Name = "a3_a" };
- scope.Database.Insert(tA3A);
+ ScopeAccessor.AmbientScope.Database.Insert(tA3A);
var tA3B = new ThingA3Dto { Id = 2, Name = "a3_b" };
- scope.Database.Insert(tA3B);
+ ScopeAccessor.AmbientScope.Database.Insert(tA3B);
var k1 = new ThingA12Dto { Name = "a", Thing1Id = tA1A.Id, Thing2Id = tA2A.Id };
- scope.Database.Insert(k1);
+ ScopeAccessor.AmbientScope.Database.Insert(k1);
var k2 = new ThingA12Dto { Name = "B", Thing1Id = tA1A.Id, Thing2Id = tA2B.Id };
- scope.Database.Insert(k2);
+ ScopeAccessor.AmbientScope.Database.Insert(k2);
string sql = @"SELECT a1.id, a1.name,
a2.id AS T2A__Id, a2.name AS T2A__Name, a3.id AS T2A__T3__Id, a3.name AS T2A__T3__Name,
@@ -453,7 +453,7 @@ JOIN zbThingA2 a2x ON a12x.thing2id=a2x.id
JOIN zbThingA3 a3x ON a2x.id=a3x.id
";
- List ts = scope.Database.Fetch(sql);
+ List ts = ScopeAccessor.AmbientScope.Database.Fetch(sql);
Assert.AreEqual(1, ts.Count);
ThingA1Dto t = ts.First();
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
index c586d496b7..4951146147 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/AuditRepositoryTest.cs
@@ -12,6 +12,7 @@ using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
@@ -35,7 +36,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
var repo = new AuditRepository((IScopeAccessor)sp, _logger);
repo.Save(new AuditItem(-1, AuditType.System, -1, UmbracoObjectTypes.Document.GetName(), "This is a System audit trail"));
- List dtos = scope.Database.Fetch("WHERE id > -1");
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch("WHERE id > -1");
Assert.That(dtos.Any(), Is.True);
Assert.That(dtos.First().Comment, Is.EqualTo("This is a System audit trail"));
@@ -63,7 +64,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
var repo = new AuditRepository((IScopeAccessor)sp, _logger);
- IEnumerable page = repo.GetPagedResultsByQuery(sp.SqlContext.Query(), 0, 10, out long total, Direction.Descending, null, null);
+ IEnumerable page = repo.GetPagedResultsByQuery(sp.CreateQuery(), 0, 10, out long total, Direction.Descending, null, null);
Assert.AreEqual(10, page.Count());
Assert.AreEqual(200, total);
@@ -91,12 +92,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
var repo = new AuditRepository((IScopeAccessor)sp, _logger);
- IQuery query = sp.SqlContext.Query().Where(x => x.UserId == -1);
+ IQuery query = sp.CreateQuery().Where(x => x.UserId == -1);
try
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = true;
IEnumerable page = repo.GetPagedResultsByQuery(
query,
@@ -105,7 +106,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
out long total,
Direction.Descending,
new[] { AuditType.Publish },
- sp.SqlContext.Query()
+ sp.CreateQuery()
.Where(x => x.UserId > -2));
Assert.AreEqual(10, page.Count());
@@ -113,8 +114,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
}
finally
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = false;
}
}
}
@@ -141,7 +142,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
var repo = new AuditRepository((IScopeAccessor)sp, _logger);
IAuditItem[] page = repo.GetPagedResultsByQuery(
- sp.SqlContext.Query(),
+ sp.CreateQuery(),
0,
9,
out long total,
@@ -178,13 +179,13 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
var repo = new AuditRepository((IScopeAccessor)sp, _logger);
IAuditItem[] page = repo.GetPagedResultsByQuery(
- sp.SqlContext.Query(),
+ sp.CreateQuery(),
0,
8,
out long total,
Direction.Descending,
null,
- sp.SqlContext.Query()
+ sp.CreateQuery()
.Where(item => item.Comment == "Content created"))
.ToArray();
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/CacheInstructionRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/CacheInstructionRepositoryTest.cs
index faa5fd9d6e..f39b4311b2 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/CacheInstructionRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/CacheInstructionRepositoryTest.cs
@@ -13,6 +13,7 @@ using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
@@ -98,7 +99,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
var repo = new CacheInstructionRepository((IScopeAccessor)sp);
repo.Add(new CacheInstruction(0, date, Instructions, OriginIdentiy, InstructionCount));
- List dtos = scope.Database.Fetch("WHERE id > -1");
+ List dtos = ScopeAccessor.AmbientScope.Database.Fetch("WHERE id > -1");
Assert.That(dtos.Any(), Is.True);
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
index 9f79414b55..38882c1638 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ContentTypeRepositoryTest.cs
@@ -17,6 +17,7 @@ using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Extensions;
using Umbraco.Cms.Tests.Common.Testing;
@@ -552,7 +553,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
ContentTypeRepository repository = ContentTypeRepository;
// Act
- IEnumerable contentTypes = repository.Get(scope.SqlContext.Query().Where(x => x.ParentId == contentType.Id));
+ IEnumerable contentTypes = repository.Get(provider.CreateQuery().Where(x => x.ParentId == contentType.Id));
// Assert
Assert.That(contentTypes.Count(), Is.EqualTo(3));
@@ -630,7 +631,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
// Act
IEnumerable contentTypes = repository.GetMany();
int count =
- scope.Database.ExecuteScalar(
+ ScopeAccessor.AmbientScope.Database.ExecuteScalar(
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
new { NodeObjectType = Constants.ObjectTypes.DocumentType });
@@ -653,7 +654,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
// Act
IEnumerable contentTypes = ((IReadRepository)repository).GetMany(allGuidIds);
int count =
- scope.Database.ExecuteScalar(
+ ScopeAccessor.AmbientScope.Database.ExecuteScalar(
"SELECT COUNT(*) FROM umbracoNode WHERE nodeObjectType = @NodeObjectType",
new { NodeObjectType = Constants.ObjectTypes.DocumentType });
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
index baa94c6e9e..8cb7686982 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
@@ -279,7 +279,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
using (IScope scope = ScopeProvider.CreateScope())
{
// Act
- IQuery query = scope.SqlContext.Query().Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.RadioButtonList);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.EditorAlias == Constants.PropertyEditors.Aliases.RadioButtonList);
IDataType[] result = DataTypeRepository.Get(query).ToArray();
// Assert
@@ -295,7 +295,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
using (IScope scope = ScopeProvider.CreateScope())
{
// Act
- IQuery query = scope.SqlContext.Query().Where(x => x.Name.StartsWith("D"));
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Name.StartsWith("D"));
int count = DataTypeRepository.Count(query);
// Assert
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
index 87f33b8589..fc3caa6acf 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DictionaryRepositoryTest.cs
@@ -191,7 +191,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
IDictionaryRepository repository = CreateRepository();
// Act
- IQuery query = provider.SqlContext.Query().Where(x => x.ItemKey == "Article");
+ IQuery query = provider.CreateQuery().Where(x => x.ItemKey == "Article");
IEnumerable result = repository.Get(query);
// Assert
@@ -211,7 +211,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
IDictionaryRepository repository = CreateRepository();
// Act
- IQuery query = provider.SqlContext.Query().Where(x => x.ItemKey.StartsWith("Read"));
+ IQuery query = provider.CreateQuery().Where(x => x.ItemKey.StartsWith("Read"));
int result = repository.Count(query);
// Assert
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
index 7207718071..2059564cd8 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DocumentRepositoryTest.cs
@@ -24,6 +24,7 @@ using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Persistence;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
+using Umbraco.Cms.Infrastructure.Scoping;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
@@ -152,11 +153,13 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
new IsolatedCaches(t => new ObjectCacheAppCache()));
IScopeProvider provider = ScopeProvider;
+ IScopeAccessor scopeAccessor = ScopeAccessor;
+
using (IScope scope = provider.CreateScope())
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out ContentTypeRepository contentTypeRepository, appCaches: realCache);
- IUmbracoDatabase udb = scope.Database;
+ IUmbracoDatabase udb = scopeAccessor.AmbientScope.Database;
udb.EnableSqlCount = false;
@@ -230,7 +233,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(true, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(true, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// change something
// save = update the current (draft) version
@@ -246,7 +249,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(true, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(true, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// unpublish = no impact on versions
((Content)content1).PublishedState = PublishedState.Unpublishing;
@@ -261,7 +264,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(false, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(false, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// change something
// save = update the current (draft) version
@@ -276,7 +279,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(false, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(false, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// publish = version
content1.PublishCulture(CultureImpact.Invariant);
@@ -292,7 +295,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(true, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(true, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// change something
// save = update the current (draft) version
@@ -310,7 +313,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(true, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(true, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// publish = new version
content1.Name = "name-4";
@@ -328,7 +331,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
Assert.AreEqual(versions[^1], repository.Get(content1.Id).VersionId);
// misc checks
- Assert.AreEqual(true, scope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
+ Assert.AreEqual(true, ScopeAccessor.AmbientScope.Database.ExecuteScalar($"SELECT published FROM {Constants.DatabaseSchema.Tables.Document} WHERE nodeId=@id", new { id = content1.Id }));
// all versions
IContent[] allVersions = repository.GetAllVersions(content1.Id).ToArray();
@@ -700,7 +703,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
IEnumerable result = repository.Get(query);
Assert.GreaterOrEqual(2, result.Count());
@@ -838,10 +841,10 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
try
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = true;
- IQuery query = scope.SqlContext.Query().Where(x => x.ParentId == root.Id);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.ParentId == root.Id);
IEnumerable result = repository.GetPage(query, 0, 20, out long totalRecords, null, Ordering.By("UpdateDate"));
Assert.AreEqual(25, totalRecords);
@@ -864,8 +867,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
}
finally
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = false;
}
}
}
@@ -878,12 +881,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Name.Contains("Text"));
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Name.Contains("Text"));
try
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = true;
IEnumerable result = repository.GetPage(query, 0, 2, out long totalRecords, null, Ordering.By("title", isCustomField: true));
@@ -896,8 +899,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
}
finally
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = false;
}
}
}
@@ -910,12 +913,12 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
try
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = true;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = true;
IEnumerable result = repository.GetPage(query, 0, 1, out long totalRecords, null, Ordering.By("Name"));
@@ -925,8 +928,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
}
finally
{
- scope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
- scope.Database.AsUmbracoDatabase().EnableSqlCount = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlTrace = false;
+ ScopeAccessor.AmbientScope.Database.AsUmbracoDatabase().EnableSqlCount = false;
}
}
}
@@ -939,7 +942,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
IEnumerable result = repository.GetPage(query, 1, 1, out long totalRecords, null, Ordering.By("Name"));
Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2));
@@ -956,7 +959,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
IEnumerable result = repository.GetPage(query, 0, 2, out long totalRecords, null, Ordering.By("Name"));
Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2));
@@ -973,7 +976,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
IEnumerable result = repository.GetPage(query, 0, 1, out long totalRecords, null, Ordering.By("Name", Direction.Descending));
Assert.That(totalRecords, Is.GreaterThanOrEqualTo(2));
@@ -990,9 +993,9 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos
{
DocumentRepository repository = CreateRepository((IScopeAccessor)provider, out _);
- IQuery query = scope.SqlContext.Query().Where(x => x.Level == 2);
+ IQuery query = ScopeProvider.CreateQuery().Where(x => x.Level == 2);
- IQuery filterQuery = scope.SqlContext.Query().Where(x => x.Name.Contains("Page 2"));
+ IQuery filterQuery = ScopeProvider.CreateQuery().Where(x => x.Name.Contains("Page 2"));
IEnumerable