Fix some of the build errors after merge
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Data;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
@@ -30,5 +30,5 @@ public class ConnectionStrings
|
||||
set => _connectionString = value.ReplaceDataDirectoryPlaceholder();
|
||||
}
|
||||
|
||||
public string ProviderName { get; set; } = DefaultProviderName;
|
||||
public string? ProviderName { get; set; } = DefaultProviderName;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ namespace Umbraco.Cms.Core.DistributedLocking;
|
||||
/// </summary>
|
||||
public interface IDistributedLockingMechanismFactory
|
||||
{
|
||||
IDistributedLockingMechanism DistributedLockingMechanism { get; }
|
||||
IDistributedLockingMechanism? DistributedLockingMechanism { get; }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Cms.Core.Install.Models
|
||||
public Guid DatabaseProviderMetadataId { get; set; }
|
||||
|
||||
[DataMember(Name = "providerName")]
|
||||
public string ProviderName { get; set; }
|
||||
public string? ProviderName { get; set; }
|
||||
|
||||
[DataMember(Name = "server")]
|
||||
public string Server { get; set; } = null!;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
{
|
||||
private object _lock = new();
|
||||
private bool _initialized;
|
||||
private IDistributedLockingMechanism _distributedLockingMechanism;
|
||||
private IDistributedLockingMechanism? _distributedLockingMechanism;
|
||||
|
||||
private readonly IOptionsMonitor<GlobalSettings> _globalSettings;
|
||||
private readonly IEnumerable<IDistributedLockingMechanism> _distributedLockingMechanisms;
|
||||
@@ -25,7 +25,7 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
_distributedLockingMechanisms = distributedLockingMechanisms;
|
||||
}
|
||||
|
||||
public IDistributedLockingMechanism DistributedLockingMechanism
|
||||
public IDistributedLockingMechanism? DistributedLockingMechanism
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -44,7 +44,7 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
|
||||
if (!string.IsNullOrEmpty(configured))
|
||||
{
|
||||
IDistributedLockingMechanism value = _distributedLockingMechanisms
|
||||
IDistributedLockingMechanism? value = _distributedLockingMechanisms
|
||||
.FirstOrDefault(x => x.GetType().FullName?.EndsWith(configured) ?? false);
|
||||
|
||||
if (value == null)
|
||||
@@ -53,7 +53,7 @@ public class DefaultDistributedLockingMechanismFactory : IDistributedLockingMech
|
||||
}
|
||||
}
|
||||
|
||||
IDistributedLockingMechanism defaultMechanism = _distributedLockingMechanisms.FirstOrDefault(x => x.Enabled);
|
||||
IDistributedLockingMechanism? defaultMechanism = _distributedLockingMechanisms.FirstOrDefault(x => x.Enabled);
|
||||
if (defaultMechanism != null)
|
||||
{
|
||||
return defaultMechanism;
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Umbraco.Cms.Core.Logging.Viewer
|
||||
else // check if it's a valid expression
|
||||
{
|
||||
// If the expression evaluates then make it into a filter
|
||||
if (SerilogExpression.TryCompile(filterExpression, null, customSerilogFunctions, out CompiledExpression compiled, out var error))
|
||||
if (SerilogExpression.TryCompile(filterExpression, null, customSerilogFunctions, out CompiledExpression? compiled, out var error))
|
||||
{
|
||||
filter = evt =>
|
||||
{
|
||||
LogEventPropertyValue result = compiled(evt);
|
||||
LogEventPropertyValue? result = compiled(evt);
|
||||
return ExpressionResult.IsTrue(result);
|
||||
};
|
||||
}
|
||||
@@ -63,12 +63,12 @@ namespace Umbraco.Cms.Core.Logging.Viewer
|
||||
private Func<LogEvent, bool>? PerformMessageLikeFilter(string filterExpression)
|
||||
{
|
||||
var filterSearch = $"@Message like '%{SerilogExpression.EscapeLikeExpressionContent(filterExpression)}%'";
|
||||
if (SerilogExpression.TryCompile(filterSearch, out CompiledExpression compiled, out var error))
|
||||
if (SerilogExpression.TryCompile(filterSearch, out CompiledExpression? compiled, out var error))
|
||||
{
|
||||
// `compiled` is a function that can be executed against `LogEvent`s:
|
||||
return evt =>
|
||||
{
|
||||
LogEventPropertyValue result = compiled(evt);
|
||||
LogEventPropertyValue? result = compiled(evt);
|
||||
return ExpressionResult.IsTrue(result);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Serilog.Expressions;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Logging.Viewer
|
||||
@@ -19,7 +20,7 @@ namespace Umbraco.Cms.Infrastructure.Logging.Viewer
|
||||
/// So we can still support the more verbose built in property names such as
|
||||
/// Exception, Level, MessageTemplate etc
|
||||
/// </summary>
|
||||
public override bool TryResolveBuiltInPropertyName(string alias, out string target)
|
||||
public override bool TryResolveBuiltInPropertyName(string alias, [MaybeNullWhen(false)] out string target)
|
||||
{
|
||||
target = alias switch
|
||||
{
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
|
||||
_connectionStrings = connectionStrings;
|
||||
_migrationPlanExecutor = migrationPlanExecutor;
|
||||
_databaseSchemaCreatorFactory = databaseSchemaCreatorFactory;
|
||||
_databaseProviderMetadata = databaseProviderMetadata;
|
||||
}
|
||||
|
||||
#region Status
|
||||
@@ -92,7 +93,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
|
||||
/// </summary>
|
||||
public bool CanConnect(string? connectionString, string providerName)
|
||||
{
|
||||
DbProviderFactory factory = _dbProviderFactoryCreator.CreateFactory(providerName);
|
||||
DbProviderFactory? factory = _dbProviderFactoryCreator.CreateFactory(providerName);
|
||||
return DbConnectionExtensions.IsConnectionAvailable(connectionString, factory);
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
|
||||
|
||||
public bool ConfigureDatabaseConnection(DatabaseModel databaseSettings, bool isTrialRun)
|
||||
{
|
||||
IDatabaseProviderMetadata providerMeta;
|
||||
IDatabaseProviderMetadata? providerMeta;
|
||||
|
||||
// if the database model is null then we will attempt quick install.
|
||||
if (databaseSettings == null)
|
||||
@@ -145,7 +146,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
|
||||
|
||||
databaseSettings = new DatabaseModel
|
||||
{
|
||||
DatabaseName = providerMeta?.DefaultDatabaseName,
|
||||
DatabaseName = providerMeta?.DefaultDatabaseName!,
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -162,15 +163,15 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install
|
||||
var connectionString = providerMeta.GenerateConnectionString(databaseSettings);
|
||||
var providerName = databaseSettings.ProviderName ?? providerMeta.ProviderName;
|
||||
|
||||
if (providerMeta.RequiresConnectionTest && !CanConnect(connectionString, providerName))
|
||||
if (providerMeta.RequiresConnectionTest && !CanConnect(connectionString, providerName!))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isTrialRun)
|
||||
{
|
||||
_configManipulator.SaveConnectionString(connectionString, providerName);
|
||||
Configure(connectionString, providerName, _globalSettings.CurrentValue.InstallMissingDatabase || providerMeta.ForceCreateDatabase);
|
||||
_configManipulator.SaveConnectionString(connectionString!, providerName);
|
||||
Configure(connectionString!, providerName, _globalSettings.CurrentValue.InstallMissingDatabase || providerMeta.ForceCreateDatabase);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_0_0.Models
|
||||
return Id == other.Id;
|
||||
}
|
||||
|
||||
public override bool Equals(object other)
|
||||
public override bool Equals(object? other)
|
||||
{
|
||||
return
|
||||
!ReferenceEquals(null, other) // other is not null
|
||||
|
||||
@@ -51,15 +51,18 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_8_1_0
|
||||
try
|
||||
{
|
||||
var obj = JsonConvert.DeserializeObject<JObject>(value);
|
||||
var allControls = obj.SelectTokens("$.sections..rows..areas..controls");
|
||||
var allControls = obj?.SelectTokens("$.sections..rows..areas..controls");
|
||||
|
||||
foreach (var control in allControls.SelectMany(c => c).OfType<JObject>())
|
||||
if (allControls is not null)
|
||||
{
|
||||
var controlValue = control["value"];
|
||||
if (controlValue?.Type == JTokenType.String)
|
||||
foreach (var control in allControls.SelectMany(c => c).OfType<JObject>())
|
||||
{
|
||||
control["value"] = UpdateMediaUrls(mediaLinkPattern, controlValue.Value<string>(), out var controlChanged);
|
||||
propertyChanged |= controlChanged;
|
||||
var controlValue = control["value"];
|
||||
if (controlValue?.Type == JTokenType.String)
|
||||
{
|
||||
control["value"] = UpdateMediaUrls(mediaLinkPattern, controlValue.Value<string>()!, out var controlChanged);
|
||||
propertyChanged |= controlChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0
|
||||
[NullSetting(NullSetting = NullSettings.NotNull)]
|
||||
[Index(IndexTypes.UniqueNonClustered, ForColumns = "loginProvider,userOrMemberKey",
|
||||
Name = "IX_" + TableName + "_LoginProvider")]
|
||||
public string LoginProvider { get; set; }
|
||||
public string LoginProvider { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Stores the key the provider uses to lookup the login
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0
|
||||
[NullSetting(NullSetting = NullSettings.NotNull)]
|
||||
[Index(IndexTypes.NonClustered, ForColumns = "loginProvider,providerKey",
|
||||
Name = "IX_" + TableName + "_ProviderKey")]
|
||||
public string ProviderKey { get; set; }
|
||||
public string ProviderKey { get; set; } = null!;
|
||||
|
||||
[Column("createDate")]
|
||||
[Constraint(Default = SystemMethods.CurrentDateTime)]
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0
|
||||
[Column("userData")]
|
||||
[NullSetting(NullSetting = NullSettings.Null)]
|
||||
[SpecialDbType(SpecialDbTypes.NTEXT)]
|
||||
public string UserData { get; set; }
|
||||
public string? UserData { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_0_0
|
||||
return;
|
||||
}
|
||||
|
||||
Database.InsertBulk(logQueriesInFile);
|
||||
Database.InsertBulk(logQueriesInFile!);
|
||||
|
||||
Context.AddPostMigration<DeleteLogViewerQueryFile>();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_2_0
|
||||
var allData = Database.Fetch<UserGroup2NodePermissionDto>();
|
||||
var toInsert = allData.Select(x => new UserGroup2NodeDto() { NodeId = x.NodeId, UserGroupId = x.UserGroupId }).Distinct(
|
||||
new DelegateEqualityComparer<UserGroup2NodeDto>(
|
||||
(x, y) => x.NodeId == y.NodeId && x.UserGroupId == y.UserGroupId,
|
||||
(x, y) => x?.NodeId == y?.NodeId && x?.UserGroupId == y?.UserGroupId,
|
||||
x => x.NodeId.GetHashCode() + x.UserGroupId.GetHashCode())).ToArray();
|
||||
Database.InsertBulk(toInsert);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_9_3_0
|
||||
private void MigrateCreatedPackageFilesToDb()
|
||||
{
|
||||
// Load data from file
|
||||
IEnumerable<PackageDefinition> packages = _packagesRepository.GetAll();
|
||||
IEnumerable<PackageDefinition> packages = _packagesRepository.GetAll().WhereNotNull();
|
||||
var createdPackageDtos = new List<CreatedPackageSchemaDto>();
|
||||
foreach (PackageDefinition package in packages)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CustomConnectionStringDatabaseProviderMetadata : IDatabaseProviderM
|
||||
public string DefaultDatabaseName => string.Empty;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ProviderName => null;
|
||||
public string? ProviderName => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool SupportsQuickInstall => false;
|
||||
@@ -35,7 +35,7 @@ public class CustomConnectionStringDatabaseProviderMetadata : IDatabaseProviderM
|
||||
public bool RequiresServer => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string ServerPlaceholder => null;
|
||||
public string? ServerPlaceholder => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool RequiresCredentials => false;
|
||||
@@ -50,6 +50,6 @@ public class CustomConnectionStringDatabaseProviderMetadata : IDatabaseProviderM
|
||||
public bool ForceCreateDatabase => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GenerateConnectionString(DatabaseModel databaseModel)
|
||||
public string? GenerateConnectionString(DatabaseModel databaseModel)
|
||||
=> databaseModel.ConnectionString;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface IDatabaseProviderMetadata
|
||||
/// Gets the database factory provider name.
|
||||
/// </summary>
|
||||
[DataMember(Name = "providerName")]
|
||||
string ProviderName { get; }
|
||||
string? ProviderName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether can be used for one click install.
|
||||
@@ -58,7 +58,7 @@ public interface IDatabaseProviderMetadata
|
||||
/// Gets a value used as input placeholder for server/hostnmae field.
|
||||
/// </summary>
|
||||
[DataMember(Name = "serverPlaceholder")]
|
||||
string ServerPlaceholder { get; }
|
||||
string? ServerPlaceholder { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a username and password are required (in general) to connect to the database
|
||||
@@ -86,5 +86,5 @@ public interface IDatabaseProviderMetadata
|
||||
/// <summary>
|
||||
/// Creates a connection string for this provider.
|
||||
/// </summary>
|
||||
string GenerateConnectionString(DatabaseModel databaseModel);
|
||||
string? GenerateConnectionString(DatabaseModel databaseModel);
|
||||
}
|
||||
|
||||
@@ -75,20 +75,20 @@ namespace Umbraco.Extensions
|
||||
return WhereIn(sql, field, values, false, null);
|
||||
}
|
||||
|
||||
public static Sql<ISqlContext> WhereIn<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object>> field, Sql<ISqlContext> values, string tableAlias)
|
||||
public static Sql<ISqlContext> WhereIn<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object?>> field, Sql<ISqlContext>? values, string tableAlias)
|
||||
{
|
||||
return sql.WhereIn(field, values, false, tableAlias);
|
||||
}
|
||||
|
||||
|
||||
public static Sql<ISqlContext> WhereLike<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object>> fieldSelector, Sql<ISqlContext> valuesSql)
|
||||
public static Sql<ISqlContext> WhereLike<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object?>> fieldSelector, Sql<ISqlContext>? valuesSql)
|
||||
{
|
||||
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(fieldSelector);
|
||||
sql.Where(fieldName + " LIKE (" + valuesSql.SQL + ")", valuesSql.Arguments);
|
||||
sql.Where(fieldName + " LIKE (" + valuesSql?.SQL + ")", valuesSql?.Arguments);
|
||||
return sql;
|
||||
}
|
||||
|
||||
public static Sql<ISqlContext> WhereLike<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object>> fieldSelector, string likeValue)
|
||||
public static Sql<ISqlContext> WhereLike<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object?>> fieldSelector, string likeValue)
|
||||
{
|
||||
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(fieldSelector);
|
||||
sql.Where(fieldName + " LIKE ('" + likeValue + "')");
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Extensions
|
||||
return WhereIn(sql, fieldSelector, valuesSql, not, null);
|
||||
}
|
||||
|
||||
private static Sql<ISqlContext> WhereIn<T>(this Sql<ISqlContext> sql, Expression<Func<T, object?>> fieldSelector, Sql? valuesSql, bool not, string tableAlias)
|
||||
private static Sql<ISqlContext> WhereIn<T>(this Sql<ISqlContext> sql, Expression<Func<T, object?>> fieldSelector, Sql? valuesSql, bool not, string? tableAlias)
|
||||
{
|
||||
var fieldName = sql.SqlContext.SqlSyntax.GetFieldName(fieldSelector, tableAlias);
|
||||
sql.Where(fieldName + (not ? " NOT" : "") +" IN (" + valuesSql?.SQL + ")", valuesSql?.Arguments);
|
||||
@@ -916,7 +916,7 @@ namespace Umbraco.Extensions
|
||||
/// <summary>
|
||||
/// Gets fields for a Dto.
|
||||
/// </summary>
|
||||
public static string ColumnsForInsert<TDto>(this Sql<ISqlContext> sql, params Expression<Func<TDto, object>>[] fields)
|
||||
public static string ColumnsForInsert<TDto>(this Sql<ISqlContext> sql, params Expression<Func<TDto, object?>>[]? fields)
|
||||
{
|
||||
if (sql == null) throw new ArgumentNullException(nameof(sql));
|
||||
return string.Join(", ", sql.GetColumns(columnExpressions: fields, withAlias: false, forInsert: true));
|
||||
@@ -1113,7 +1113,7 @@ namespace Umbraco.Extensions
|
||||
}
|
||||
|
||||
return queryColumns
|
||||
.Select(x => sql.SqlContext.SqlSyntax.GetColumn(sql.SqlContext.DatabaseType, tableName, x.Value.ColumnName, GetAlias(x.Value), referenceName, forInsert: forInsert))
|
||||
.Select(x => sql.SqlContext.SqlSyntax.GetColumn(sql.SqlContext.DatabaseType, tableName, x.Value.ColumnName, GetAlias(x.Value)!, referenceName, forInsert: forInsert))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -469,27 +469,27 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
public Guid ChildNodeKey { get; set; }
|
||||
|
||||
[Column(Name = "nodeName")]
|
||||
public string ChildNodeName { get; set; }
|
||||
public string? ChildNodeName { get; set; }
|
||||
|
||||
[Column(Name = "nodeObjectType")]
|
||||
public Guid ChildNodeObjectType { get; set; }
|
||||
|
||||
[Column(Name = "contentTypeIcon")]
|
||||
public string ChildContentTypeIcon { get; set; }
|
||||
public string? ChildContentTypeIcon { get; set; }
|
||||
|
||||
[Column(Name = "contentTypeAlias")]
|
||||
public string ChildContentTypeAlias { get; set; }
|
||||
public string? ChildContentTypeAlias { get; set; }
|
||||
|
||||
[Column(Name = "contentTypeName")]
|
||||
public string ChildContentTypeName { get; set; }
|
||||
public string? ChildContentTypeName { get; set; }
|
||||
|
||||
|
||||
|
||||
[Column(Name = "relationTypeName")]
|
||||
public string RelationTypeName { get; set; }
|
||||
public string? RelationTypeName { get; set; }
|
||||
|
||||
[Column(Name = "relationTypeAlias")]
|
||||
public string RelationTypeAlias { get; set; }
|
||||
public string? RelationTypeAlias { get; set; }
|
||||
|
||||
[Column(Name = "relationTypeIsDependency")]
|
||||
public bool RelationTypeIsDependency { get; set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
public IEnumerable<RelationItem> GetPagedItemsWithRelations(int[] ids, long pageIndex, int pageSize,
|
||||
bool filterMustBeIsDependency, out long totalRecords)
|
||||
{
|
||||
var sql = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select(
|
||||
var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql().Select(
|
||||
"[pn].[id] as nodeId",
|
||||
"[pn].[uniqueId] as nodeKey",
|
||||
"[pn].[text] as nodeName",
|
||||
@@ -46,43 +46,43 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
|
||||
if (ids.Any())
|
||||
{
|
||||
sql = sql.Where<NodeDto>(x => ids.Contains(x.NodeId), "pn");
|
||||
sql = sql?.Where<NodeDto>(x => ids.Contains(x.NodeId), "pn");
|
||||
}
|
||||
|
||||
if (filterMustBeIsDependency)
|
||||
{
|
||||
sql = sql.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
sql = sql?.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
}
|
||||
|
||||
// Ordering is required for paging
|
||||
sql = sql.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
sql = sql?.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
|
||||
var pagedResult = _scopeAccessor.AmbientScope.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
var pagedResult = _scopeAccessor.AmbientScope?.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult?.TotalItems);
|
||||
|
||||
return pagedResult.Items.Select(MapDtoToEntity);
|
||||
return pagedResult?.Items.Select(MapDtoToEntity) ?? Enumerable.Empty<RelationItem>();
|
||||
}
|
||||
|
||||
public IEnumerable<RelationItem> GetPagedDescendantsInReferences(int parentId, long pageIndex, int pageSize, bool filterMustBeIsDependency,
|
||||
out long totalRecords)
|
||||
{
|
||||
var syntax = _scopeAccessor.AmbientScope.Database.SqlContext.SqlSyntax;
|
||||
var syntax = _scopeAccessor.AmbientScope?.Database.SqlContext.SqlSyntax;
|
||||
|
||||
// Gets the path of the parent with ",%" added
|
||||
var subsubQuery = _scopeAccessor.AmbientScope.Database.SqlContext.Sql()
|
||||
.Select(syntax.GetConcat("[node].[path]", "',%'"))
|
||||
var subsubQuery = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql()
|
||||
.Select(syntax?.GetConcat("[node].[path]", "',%'"))
|
||||
.From<NodeDto>("node")
|
||||
.Where<NodeDto>(x => x.NodeId == parentId, "node");
|
||||
|
||||
|
||||
// Gets the descendants of the parent node
|
||||
Sql<ISqlContext> subQuery = _scopeAccessor.AmbientScope.Database.SqlContext.Sql()
|
||||
Sql<ISqlContext>? subQuery = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql()
|
||||
.Select<NodeDto>(x => x.NodeId)
|
||||
.From<NodeDto>()
|
||||
.WhereLike<NodeDto>(x => x.Path, subsubQuery);
|
||||
|
||||
// Get all relations where parent is in the sub query
|
||||
var sql = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select(
|
||||
var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql().Select(
|
||||
"[pn].[id] as nodeId",
|
||||
"[pn].[uniqueId] as nodeKey",
|
||||
"[pn].[text] as nodeName",
|
||||
@@ -101,23 +101,23 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
.LeftJoin<ContentDto>("c").On<NodeDto, ContentDto>((left, right) => left.NodeId == right.NodeId, aliasLeft:"pn", aliasRight:"c")
|
||||
.LeftJoin<ContentTypeDto>("ct").On<ContentDto, ContentTypeDto>((left, right) => left.ContentTypeId == right.NodeId, aliasLeft:"c", aliasRight:"ct")
|
||||
.LeftJoin<NodeDto>("ctn").On<ContentTypeDto, NodeDto>((left, right) => left.NodeId == right.NodeId, aliasLeft:"ct", aliasRight:"ctn")
|
||||
.WhereIn((System.Linq.Expressions.Expression<Func<NodeDto, object>>)(x => x.NodeId), subQuery, "pn");
|
||||
.WhereIn((System.Linq.Expressions.Expression<Func<NodeDto, object?>>)(x => x.NodeId), subQuery, "pn");
|
||||
if (filterMustBeIsDependency)
|
||||
{
|
||||
sql = sql.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
sql = sql?.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
}
|
||||
// Ordering is required for paging
|
||||
sql = sql.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
sql = sql?.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
|
||||
var pagedResult = _scopeAccessor.AmbientScope.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
var pagedResult = _scopeAccessor.AmbientScope?.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult?.TotalItems);
|
||||
|
||||
return pagedResult.Items.Select(MapDtoToEntity);
|
||||
return pagedResult?.Items.Select(MapDtoToEntity) ?? Enumerable.Empty<RelationItem>();
|
||||
}
|
||||
|
||||
public IEnumerable<RelationItem> GetPagedRelationsForItems(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency, out long totalRecords)
|
||||
{
|
||||
var sql = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select(
|
||||
var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql().Select(
|
||||
"[cn].[id] as nodeId",
|
||||
"[cn].[uniqueId] as nodeKey",
|
||||
"[cn].[text] as nodeName",
|
||||
@@ -139,21 +139,21 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
|
||||
|
||||
if (ids.Any())
|
||||
{
|
||||
sql = sql.Where<NodeDto>(x => ids.Contains(x.NodeId), "pn");
|
||||
sql = sql?.Where<NodeDto>(x => ids.Contains(x.NodeId), "pn");
|
||||
}
|
||||
|
||||
if (filterMustBeIsDependency)
|
||||
{
|
||||
sql = sql.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
sql = sql?.Where<RelationTypeDto>(rt => rt.IsDependency, "umbracoRelationType");
|
||||
}
|
||||
|
||||
// Ordering is required for paging
|
||||
sql = sql.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
sql = sql?.OrderBy<RelationTypeDto>(x => x.Alias);
|
||||
|
||||
var pagedResult = _scopeAccessor.AmbientScope.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult.TotalItems);
|
||||
var pagedResult = _scopeAccessor.AmbientScope?.Database.Page<RelationItemDto>(pageIndex + 1, pageSize, sql);
|
||||
totalRecords = Convert.ToInt32(pagedResult?.TotalItems);
|
||||
|
||||
return pagedResult.Items.Select(MapDtoToEntity);
|
||||
return pagedResult?.Items.Select(MapDtoToEntity) ?? Enumerable.Empty<RelationItem>();
|
||||
}
|
||||
|
||||
private RelationItem MapDtoToEntity(RelationItemDto dto)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
/// </summary>
|
||||
public interface ISqlSyntaxProvider
|
||||
{
|
||||
DatabaseType GetUpdatedDatabaseType(DatabaseType current, string connectionString);
|
||||
DatabaseType GetUpdatedDatabaseType(DatabaseType current, string? connectionString);
|
||||
|
||||
string ProviderName { get; }
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
string GetStringColumnWildcardComparison(string column, int paramIndex, TextColumnType columnType);
|
||||
string GetConcat(params string[] args);
|
||||
|
||||
string GetColumn(DatabaseType dbType, string tableName, string columnName, string columnAlias, string referenceName = null, bool forInsert = false);
|
||||
string GetColumn(DatabaseType dbType, string tableName, string columnName, string columnAlias, string? referenceName = null, bool forInsert = false);
|
||||
|
||||
string GetQuotedTableName(string? tableName);
|
||||
string GetQuotedColumnName(string? columnName);
|
||||
@@ -140,7 +140,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
bool TryGetDefaultConstraint(IDatabase db, string? tableName, string columnName, [MaybeNullWhen(false)] out string constraintName);
|
||||
|
||||
|
||||
string GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object>> fieldSelector, string tableAlias = null);
|
||||
string GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object?>> fieldSelector, string? tableAlias = null);
|
||||
|
||||
/// <summary>
|
||||
/// Appends the relevant ForUpdate hint.
|
||||
@@ -158,8 +158,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
Sql<ISqlContext>.SqlJoinClause<ISqlContext> LeftJoinWithNestedJoin<TDto>(
|
||||
Sql<ISqlContext> sql,
|
||||
Func<Sql<ISqlContext>, Sql<ISqlContext>> nestedJoin,
|
||||
string alias = null);
|
||||
string? alias = null);
|
||||
|
||||
IDictionary<Type, IScalarMapper> ScalarMappers { get; }
|
||||
IDictionary<Type, IScalarMapper>? ScalarMappers { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
return dbTypeMap.Create();
|
||||
}
|
||||
|
||||
public virtual DatabaseType GetUpdatedDatabaseType(DatabaseType current, string connectionString) => current;
|
||||
public virtual DatabaseType GetUpdatedDatabaseType(DatabaseType current, string? connectionString) => current;
|
||||
|
||||
public abstract string ProviderName { get; }
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
|
||||
public virtual string GetSpecialDbType(SpecialDbType dbType, int customSize) => $"{GetSpecialDbType(dbType)}({customSize})";
|
||||
|
||||
public virtual string GetColumn(DatabaseType dbType, string tableName, string columnName, string columnAlias, string referenceName = null, bool forInsert = false)
|
||||
public virtual string GetColumn(DatabaseType dbType, string tableName, string columnName, string columnAlias, string? referenceName = null, bool forInsert = false)
|
||||
{
|
||||
tableName = GetQuotedTableName(tableName);
|
||||
columnName = GetQuotedColumnName(columnName);
|
||||
@@ -263,16 +263,16 @@ namespace Umbraco.Cms.Infrastructure.Persistence.SqlSyntax
|
||||
|
||||
public abstract bool TryGetDefaultConstraint(IDatabase db, string? tableName, string columnName, [MaybeNullWhen(false)] out string constraintName);
|
||||
|
||||
public virtual string GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object>> fieldSelector, string tableAlias = null) => this.GetFieldName(fieldSelector, tableAlias);
|
||||
public virtual string GetFieldNameForUpdate<TDto>(Expression<Func<TDto, object?>> fieldSelector, string? tableAlias = null) => this.GetFieldName(fieldSelector, tableAlias);
|
||||
|
||||
public virtual Sql<ISqlContext> InsertForUpdateHint(Sql<ISqlContext> sql) => sql;
|
||||
|
||||
public virtual Sql<ISqlContext> AppendForUpdateHint(Sql<ISqlContext> sql) => sql;
|
||||
|
||||
public abstract Sql<ISqlContext>.SqlJoinClause<ISqlContext> LeftJoinWithNestedJoin<TDto>(Sql<ISqlContext> sql, Func<Sql<ISqlContext>, Sql<ISqlContext>> nestedJoin, string alias = null);
|
||||
public abstract Sql<ISqlContext>.SqlJoinClause<ISqlContext> LeftJoinWithNestedJoin<TDto>(Sql<ISqlContext> sql, Func<Sql<ISqlContext>, Sql<ISqlContext>> nestedJoin, string? alias = null);
|
||||
|
||||
|
||||
public virtual IDictionary<Type, IScalarMapper> ScalarMappers => null;
|
||||
public virtual IDictionary<Type, IScalarMapper>? ScalarMappers => null;
|
||||
|
||||
public virtual bool DoesTableExist(IDatabase db, string tableName) => GetTablesInSchema(db).Contains(tableName);
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
|
||||
return base.ExecuteScalar<T>(sql, commandType, args);
|
||||
}
|
||||
|
||||
if (!SqlContext.SqlSyntax.ScalarMappers.TryGetValue(typeof(T), out IScalarMapper mapper))
|
||||
if (!SqlContext.SqlSyntax.ScalarMappers.TryGetValue(typeof(T), out IScalarMapper? mapper))
|
||||
{
|
||||
return base.ExecuteScalar<T>(sql, commandType, args);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
|
||||
private bool _upgrading;
|
||||
private bool _initialized;
|
||||
|
||||
private ConnectionStrings _umbracoConnectionString;
|
||||
private ConnectionStrings? _umbracoConnectionString;
|
||||
|
||||
private DbProviderFactory? _dbProviderFactory = null;
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
|
||||
cfg.UsingDatabase(CreateDatabaseInstance) // creating UmbracoDatabase instances
|
||||
.WithFluentConfig(config); // with proper configuration
|
||||
|
||||
foreach (IProviderSpecificInterceptor interceptor in _dbProviderFactoryCreator.GetProviderSpecificInterceptors(ProviderName))
|
||||
foreach (IProviderSpecificInterceptor interceptor in _dbProviderFactoryCreator.GetProviderSpecificInterceptors(ProviderName!))
|
||||
{
|
||||
cfg.WithInterceptor(interceptor);
|
||||
}
|
||||
@@ -274,6 +274,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new UmbracoDatabase(
|
||||
ConnectionString,
|
||||
SqlContext,
|
||||
@@ -282,6 +283,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
|
||||
_bulkSqlInsertProvider,
|
||||
_databaseSchemaCreatorFactory,
|
||||
_pocoMappers);
|
||||
}
|
||||
|
||||
protected override void DisposeResources()
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Umbraco.Cms.Infrastructure.Runtime
|
||||
private readonly string _lockFilePath;
|
||||
private readonly string _releaseSignalFilePath;
|
||||
|
||||
private FileStream _lockFileStream;
|
||||
private Task _listenForReleaseSignalFileTask;
|
||||
private FileStream? _lockFileStream;
|
||||
private Task? _listenForReleaseSignalFileTask;
|
||||
|
||||
public FileSystemMainDomLock(
|
||||
ILogger<FileSystemMainDomLock> logger,
|
||||
|
||||
@@ -1083,7 +1083,7 @@ namespace Umbraco.Cms.Core.Scoping
|
||||
Guid instanceId,
|
||||
ref Dictionary<Guid, Dictionary<int, int>>? locks,
|
||||
ref HashSet<int>? locksSet,
|
||||
Action<int, TimeSpan> obtainLock,
|
||||
Action<int, TimeSpan?> obtainLock,
|
||||
TimeSpan? timeout,
|
||||
int lockId)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user