Fixed NRT issues

This commit is contained in:
Bjarke Berg
2022-06-02 20:53:16 +02:00
parent d086b21332
commit 3d8f81025b
3 changed files with 11 additions and 6 deletions

View File

@@ -263,7 +263,7 @@ namespace Umbraco.Extensions
return sql.OrderBy("(" + sql.SqlContext.SqlSyntax.GetFieldName(field) + ")");
}
public static Sql<ISqlContext> OrderBy<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object>> field, string alias)
public static Sql<ISqlContext> OrderBy<TDto>(this Sql<ISqlContext> sql, Expression<Func<TDto, object?>> field, string alias)
{
return sql.OrderBy("(" + sql.SqlContext.SqlSyntax.GetFieldName(field, alias) + ")");
}

View File

@@ -69,6 +69,11 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
private Sql<ISqlContext> GetInnerUnionSql()
{
if (_scopeAccessor.AmbientScope is null)
{
throw new InvalidOperationException("No Ambient Scope available");
}
var innerUnionSqlChild = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select(
"[cr].childId as id", "[cr].parentId as otherId", "[rt].[alias]", "[rt].[name]", "[rt].[isDependency]", "[rt].[dual]")
.From<RelationDto>("cr").InnerJoin<RelationTypeDto>("rt")
@@ -134,7 +139,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
aliasRight: "ct")
.LeftJoin<NodeDto>("ctn").On<ContentTypeDto, NodeDto>((left, right) => left.NodeId == right.NodeId,
aliasLeft: "ct", aliasRight: "ctn");
sql = sql.WhereIn((System.Linq.Expressions.Expression<Func<NodeDto, object?>>)(x => x.NodeId), subQuery, "n");
sql = sql?.WhereIn((System.Linq.Expressions.Expression<Func<NodeDto, object?>>)(x => x.NodeId), subQuery, "n");
if (filterMustBeIsDependency)
{
@@ -205,10 +210,10 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
public int OtherId { get; set; }
[Column("alias")]
public string Alias { get; set; }
public string? Alias { get; set; }
[Column("name")]
public string Name { get; set; }
public string? Name { get; set; }
[Column("isDependency")]
public bool IsDependency { get; set; }

View File

@@ -145,7 +145,7 @@ namespace Umbraco.Cms.Core.Routing
var route = contentCache?.GetRouteById(publishedContent.Id, culture);
if (!IsNotRoute(route))
{
oldRoutes[new ContentIdAndCulture(publishedContent.Id, culture)] = new ContentKeyAndOldRoute(publishedContent.Key, route);
oldRoutes[new ContentIdAndCulture(publishedContent.Id, culture)] = new ContentKeyAndOldRoute(publishedContent.Key, route!);
}
else if (string.IsNullOrEmpty(culture))
{
@@ -153,7 +153,7 @@ namespace Umbraco.Cms.Core.Routing
var languages = _localizationService.GetAllLanguages();
foreach (var language in languages)
{
route = contentCache.GetRouteById(publishedContent.Id, language.IsoCode);
route = contentCache?.GetRouteById(publishedContent.Id, language.IsoCode);
if (!IsNotRoute(route))
{
oldRoutes[new ContentIdAndCulture(publishedContent.Id, language.IsoCode)] = new ContentKeyAndOldRoute(publishedContent.Key, route!);