From 09731a916807d7876a3015f2fd9ae27796df4867 Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Mon, 2 May 2022 10:57:38 +0200 Subject: [PATCH] v10: Remove LegacyDistinctBy (#12326) * Obsolete LegacyDistinctBy * Remove usage of LegacyDistinctBy * Remove LegacyDistinctBy --- .../Extensions/EnumerableExtensions.cs | 12 -- .../Packaging/PackagesRepository.cs | 2 +- .../Routing/UrlProviderExtensions.cs | 112 +++++------------- ...peServiceBaseOfTRepositoryTItemTService.cs | 8 +- .../Manifest/ManifestParser.cs | 37 +++++- .../DeleteKeysAndIndexesBuilder.cs | 6 +- .../Install/DatabaseSchemaCreator.cs | 50 +++----- .../Implement/ExternalLoginRepository.cs | 4 +- .../Implement/MemberGroupRepository.cs | 4 +- .../Repositories/Implement/UserRepository.cs | 2 +- 10 files changed, 91 insertions(+), 146 deletions(-) diff --git a/src/Umbraco.Core/Extensions/EnumerableExtensions.cs b/src/Umbraco.Core/Extensions/EnumerableExtensions.cs index ba420003e5..28f4844f00 100644 --- a/src/Umbraco.Core/Extensions/EnumerableExtensions.cs +++ b/src/Umbraco.Core/Extensions/EnumerableExtensions.cs @@ -75,18 +75,6 @@ namespace Umbraco.Extensions yield return result; } - /// The legacy distinct by. - /// The source. - /// The key selector. - /// Source type - /// Key type - /// the unique list - public static IEnumerable LegacyDistinctBy(this IEnumerable source, Func keySelector) - where TKey : IEquatable - { - return source.Distinct(DelegateEqualityComparer.CompareMember(keySelector)); - } - /// /// Returns a sequence of length whose elements are the result of invoking . /// diff --git a/src/Umbraco.Core/Packaging/PackagesRepository.cs b/src/Umbraco.Core/Packaging/PackagesRepository.cs index a997dfe977..174faa37fd 100644 --- a/src/Umbraco.Core/Packaging/PackagesRepository.cs +++ b/src/Umbraco.Core/Packaging/PackagesRepository.cs @@ -577,7 +577,7 @@ namespace Umbraco.Cms.Core.Packaging ////Now, we have all property Ids/Aliases and their referenced document Ids and tags //var allExportedTaggedEntities = allTaggedEntities.Where(x => allExportedIds.Contains(x.EntityId)) - // .LegacyDistinctBy(x => x.EntityId) + // .DistinctBy(x => x.EntityId) // .OrderBy(x => x.EntityId); //foreach (var taggedEntity in allExportedTaggedEntities) diff --git a/src/Umbraco.Core/Routing/UrlProviderExtensions.cs b/src/Umbraco.Core/Routing/UrlProviderExtensions.cs index 7686b1a49a..5f28bee2b7 100644 --- a/src/Umbraco.Core/Routing/UrlProviderExtensions.cs +++ b/src/Umbraco.Core/Routing/UrlProviderExtensions.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Models; @@ -33,55 +29,16 @@ namespace Umbraco.Extensions UriUtility uriUtility, IPublishedUrlProvider publishedUrlProvider) { - if (content == null) - { - throw new ArgumentNullException(nameof(content)); - } - - if (publishedRouter == null) - { - throw new ArgumentNullException(nameof(publishedRouter)); - } - - if (umbracoContext == null) - { - throw new ArgumentNullException(nameof(umbracoContext)); - } - - if (localizationService == null) - { - throw new ArgumentNullException(nameof(localizationService)); - } - - if (textService == null) - { - throw new ArgumentNullException(nameof(textService)); - } - - if (contentService == null) - { - throw new ArgumentNullException(nameof(contentService)); - } - - if (logger == null) - { - throw new ArgumentNullException(nameof(logger)); - } - - if (publishedUrlProvider == null) - { - throw new ArgumentNullException(nameof(publishedUrlProvider)); - } - - if (uriUtility == null) - { - throw new ArgumentNullException(nameof(uriUtility)); - } - - if (variationContextAccessor == null) - { - throw new ArgumentNullException(nameof(variationContextAccessor)); - } + ArgumentNullException.ThrowIfNull(content); + ArgumentNullException.ThrowIfNull(publishedRouter); + ArgumentNullException.ThrowIfNull(umbracoContext); + ArgumentNullException.ThrowIfNull(localizationService); + ArgumentNullException.ThrowIfNull(textService); + ArgumentNullException.ThrowIfNull(contentService); + ArgumentNullException.ThrowIfNull(variationContextAccessor); + ArgumentNullException.ThrowIfNull(logger); + ArgumentNullException.ThrowIfNull(uriUtility); + ArgumentNullException.ThrowIfNull(publishedUrlProvider); var result = new List(); @@ -107,9 +64,7 @@ namespace Umbraco.Extensions // get all URLs for all cultures // in a HashSet, so de-duplicates too - foreach (UrlInfo cultureUrl in await GetContentUrlsByCultureAsync(content, cultures, publishedRouter, - umbracoContext, contentService, textService, variationContextAccessor, logger, uriUtility, - publishedUrlProvider)) + foreach (UrlInfo cultureUrl in await GetContentUrlsByCultureAsync(content, cultures, publishedRouter, umbracoContext, contentService, textService, variationContextAccessor, logger, uriUtility, publishedUrlProvider)) { urls.Add(cultureUrl); } @@ -120,25 +75,19 @@ namespace Umbraco.Extensions // in some cases there will be the same URL for multiple cultures: // * The entire branch is invariant // * If there are less domain/cultures assigned to the branch than the number of cultures/languages installed - if (urlGroup.Key) { - result.AddRange(urlGroup.LegacyDistinctBy(x => x!.Text.ToUpperInvariant()) - .OrderBy(x => x.Text).ThenBy(x => x.Culture)); + result.AddRange(urlGroup.DistinctBy(x => x.Text, StringComparer.OrdinalIgnoreCase).OrderBy(x => x.Text).ThenBy(x => x.Culture)); } else { result.AddRange(urlGroup); } - - - } // get the 'other' URLs - ie not what you'd get with GetUrl() but URLs that would route to the document, nevertheless. // for these 'other' URLs, we don't check whether they are routable, collide, anything - we just report them. - foreach (UrlInfo otherUrl in publishedUrlProvider.GetOtherUrls(content.Id).OrderBy(x => x.Text) - .ThenBy(x => x.Culture)) + foreach (UrlInfo otherUrl in publishedUrlProvider.GetOtherUrls(content.Id).OrderBy(x => x.Text).ThenBy(x => x.Culture)) { // avoid duplicates if (urls.Add(otherUrl)) @@ -202,8 +151,7 @@ namespace Umbraco.Extensions // got a URL, deal with collisions, add URL default: // detect collisions, etc - Attempt hasCollision = await DetectCollisionAsync(logger, content, url, culture, - umbracoContext, publishedRouter, textService, variationContextAccessor, uriUtility); + Attempt hasCollision = await DetectCollisionAsync(logger, content, url, culture, umbracoContext, publishedRouter, textService, variationContextAccessor, uriUtility); if (hasCollision.Success && hasCollision.Result is not null) { result.Add(hasCollision.Result); @@ -220,8 +168,7 @@ namespace Umbraco.Extensions return result; } - private static UrlInfo HandleCouldNotGetUrl(IContent content, string culture, IContentService contentService, - ILocalizedTextService textService) + private static UrlInfo HandleCouldNotGetUrl(IContent content, string culture, IContentService contentService, ILocalizedTextService textService) { // document has a published version yet its URL is "#" => a parent must be // unpublished, walk up the tree until we find it, and report. @@ -229,8 +176,8 @@ namespace Umbraco.Extensions do { parent = parent.ParentId > 0 ? contentService.GetParent(parent) : null; - } while (parent != null && parent.Published && - (!parent.ContentType.VariesByCulture() || parent.IsCulturePublished(culture))); + } + while (parent != null && parent.Published && (!parent.ContentType.VariesByCulture() || parent.IsCulturePublished(culture))); if (parent == null) { @@ -241,18 +188,22 @@ namespace Umbraco.Extensions if (!parent.Published) { // totally not published - return UrlInfo.Message(textService.Localize("content", "parentNotPublished", new[] { parent.Name }), - culture); + return UrlInfo.Message(textService.Localize("content", "parentNotPublished", new[] { parent.Name }), culture); } // culture not published - return UrlInfo.Message(textService.Localize("content", "parentCultureNotPublished", new[] { parent.Name }), - culture); + return UrlInfo.Message(textService.Localize("content", "parentCultureNotPublished", new[] { parent.Name }), culture); } - private static async Task> DetectCollisionAsync(ILogger logger, IContent content, string url, - string culture, IUmbracoContext umbracoContext, IPublishedRouter publishedRouter, - ILocalizedTextService textService, IVariationContextAccessor variationContextAccessor, + private static async Task> DetectCollisionAsync( + ILogger logger, + IContent content, + string url, + string culture, + IUmbracoContext umbracoContext, + IPublishedRouter publishedRouter, + ILocalizedTextService textService, + IVariationContextAccessor variationContextAccessor, UriUtility uriUtility) { // test for collisions on the 'main' URL @@ -264,14 +215,11 @@ namespace Umbraco.Extensions uri = uriUtility.UriToUmbraco(uri); IPublishedRequestBuilder builder = await publishedRouter.CreateRequestAsync(uri); - IPublishedRequest pcr = - await publishedRouter.RouteRequestAsync(builder, new RouteRequestOptions(RouteDirection.Outbound)); + IPublishedRequest pcr = await publishedRouter.RouteRequestAsync(builder, new RouteRequestOptions(RouteDirection.Outbound)); if (!pcr.HasPublishedContent()) { - const string logMsg = nameof(DetectCollisionAsync) + - " did not resolve a content item for original url: {Url}, translated to {TranslatedUrl} and culture: {Culture}"; - + const string logMsg = nameof(DetectCollisionAsync) + " did not resolve a content item for original url: {Url}, translated to {TranslatedUrl} and culture: {Culture}"; logger.LogDebug(logMsg, url, uri, culture); var urlInfo = UrlInfo.Message(textService.Localize("content", "routeErrorCannotRoute"), culture); diff --git a/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs b/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs index 8c97ff5a2d..fc7d958c40 100644 --- a/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs +++ b/src/Umbraco.Core/Services/ContentTypeServiceBaseOfTRepositoryTItemTService.cs @@ -623,7 +623,7 @@ namespace Umbraco.Cms.Core.Services scope.Notifications.Publish(GetContentTypeChangedNotification(changes, eventMessages)); - DeletedNotification deletedNotification = GetDeletedNotification(deleted.LegacyDistinctBy(x => x!.Id), eventMessages); + DeletedNotification deletedNotification = GetDeletedNotification(deleted.DistinctBy(x => x.Id), eventMessages); deletedNotification.WithStateFrom(deletingNotification); scope.Notifications.Publish(deletedNotification); @@ -649,9 +649,7 @@ namespace Umbraco.Cms.Core.Services scope.WriteLock(WriteLockIds); // all descendants are going to be deleted - TItem[] allDescendantsAndSelf = itemsA.SelectMany(xx => GetDescendants(xx.Id, true)) - .LegacyDistinctBy(x => x!.Id) - .ToArray(); + TItem[] allDescendantsAndSelf = itemsA.SelectMany(xx => GetDescendants(xx.Id, true)).DistinctBy(x => x.Id).ToArray(); TItem[] deleted = allDescendantsAndSelf; // all impacted (through composition) probably lose some properties @@ -681,7 +679,7 @@ namespace Umbraco.Cms.Core.Services scope.Notifications.Publish(GetContentTypeChangedNotification(changes, eventMessages)); - DeletedNotification deletedNotification = GetDeletedNotification(deleted.LegacyDistinctBy(x => x!.Id), eventMessages); + DeletedNotification deletedNotification = GetDeletedNotification(deleted.DistinctBy(x => x.Id), eventMessages); deletedNotification.WithStateFrom(deletingNotification); scope.Notifications.Publish(deletedNotification); diff --git a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs index 10ee362dfd..bdf5e5c620 100644 --- a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs +++ b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs @@ -140,6 +140,7 @@ namespace Umbraco.Cms.Core.Manifest scriptsPerBundleOption = new List(); scripts[manifest.BundleOptions] = scriptsPerBundleOption; } + scriptsPerBundleOption.Add(new ManifestAssets(manifest.PackageName, manifest.Scripts)); } @@ -150,15 +151,39 @@ namespace Umbraco.Cms.Core.Manifest stylesPerBundleOption = new List(); stylesheets[manifest.BundleOptions] = stylesPerBundleOption; } + stylesPerBundleOption.Add(new ManifestAssets(manifest.PackageName, manifest.Stylesheets)); } - if (manifest.PropertyEditors != null) propertyEditors.AddRange(manifest.PropertyEditors); - if (manifest.ParameterEditors != null) parameterEditors.AddRange(manifest.ParameterEditors); - if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors); - if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps); - if (manifest.Dashboards != null) dashboards.AddRange(manifest.Dashboards); - if (manifest.Sections != null) sections.AddRange(manifest.Sections.LegacyDistinctBy(x => x!.Alias.ToLowerInvariant())); + if (manifest.PropertyEditors != null) + { + propertyEditors.AddRange(manifest.PropertyEditors); + } + + if (manifest.ParameterEditors != null) + { + parameterEditors.AddRange(manifest.ParameterEditors); + } + + if (manifest.GridEditors != null) + { + gridEditors.AddRange(manifest.GridEditors); + } + + if (manifest.ContentApps != null) + { + contentApps.AddRange(manifest.ContentApps); + } + + if (manifest.Dashboards != null) + { + dashboards.AddRange(manifest.Dashboards); + } + + if (manifest.Sections != null) + { + sections.AddRange(manifest.Sections.DistinctBy(x => x.Alias, StringComparer.OrdinalIgnoreCase)); + } } return new CompositePackageManifest( diff --git a/src/Umbraco.Infrastructure/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs index 09c6e04fe1..90ade43d6d 100644 --- a/src/Umbraco.Infrastructure/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs +++ b/src/Umbraco.Infrastructure/Migrations/Expressions/Delete/KeysAndIndexes/DeleteKeysAndIndexesBuilder.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NPoco; using Umbraco.Cms.Infrastructure.Migrations.Expressions.Common; using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax; @@ -44,10 +44,10 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Expressions.Delete.KeysAndIndexe _context.BuildingExpression = false; //get a list of all constraints - this will include all PK, FK and unique constraints - var tableConstraints = _context.SqlContext.SqlSyntax.GetConstraintsPerTable(_context.Database).LegacyDistinctBy(x => x!.Item2).ToList(); + var tableConstraints = _context.SqlContext.SqlSyntax.GetConstraintsPerTable(_context.Database).DistinctBy(x => x.Item2).ToList(); //get a list of defined indexes - this will include all indexes, unique indexes and unique constraint indexes - var indexes = _context.SqlContext.SqlSyntax.GetDefinedIndexesDefinitions(_context.Database).LegacyDistinctBy(x => x!.IndexName).ToList(); + var indexes = _context.SqlContext.SqlSyntax.GetDefinedIndexesDefinitions(_context.Database).DistinctBy(x => x.IndexName).ToList(); var uniqueConstraintNames = tableConstraints.Where(x => !x.Item2.InvariantStartsWith("PK_") && !x.Item2.InvariantStartsWith("FK_")).Select(x => x.Item2); var indexNames = indexes.Select(x => x.IndexName).ToList(); diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs index 678ae1ae7a..d4527909e9 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseSchemaCreator.cs @@ -227,21 +227,16 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install private void ValidateDbConstraints(DatabaseSchemaResult result) { //Check constraints in configured database against constraints in schema - var constraintsInDatabase = SqlSyntax.GetConstraintsPerColumn(_database).LegacyDistinctBy(x => x!.Item3).ToList(); - var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("FK_")) - .Select(x => x.Item3).ToList(); - var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("PK_")) - .Select(x => x.Item3).ToList(); + var constraintsInDatabase = SqlSyntax.GetConstraintsPerColumn(_database).DistinctBy(x => x.Item3).ToList(); + var foreignKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("FK_")).Select(x => x.Item3).ToList(); + var primaryKeysInDatabase = constraintsInDatabase.Where(x => x.Item3.InvariantStartsWith("PK_")).Select(x => x.Item3).ToList(); - var unknownConstraintsInDatabase = - constraintsInDatabase.Where( - x => - x.Item3.InvariantStartsWith("FK_") == false && x.Item3.InvariantStartsWith("PK_") == false && - x.Item3.InvariantStartsWith("IX_") == false).Select(x => x.Item3).ToList(); - var foreignKeysInSchema = - result.TableDefinitions.SelectMany(x => x.ForeignKeys.Select(y => y.Name)).Where(x => x is not null).ToList(); - var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)) - .Where(x => x.IsNullOrWhiteSpace() == false).ToList(); + var unknownConstraintsInDatabase = constraintsInDatabase.Where( + x => x.Item3.InvariantStartsWith("FK_") == false && x.Item3.InvariantStartsWith("PK_") == false && x.Item3.InvariantStartsWith("IX_") == false + ).Select(x => x.Item3).ToList(); + + var foreignKeysInSchema = result.TableDefinitions.SelectMany(x => x.ForeignKeys.Select(y => y.Name)).Where(x => x is not null).ToList(); + var primaryKeysInSchema = result.TableDefinitions.SelectMany(x => x.Columns.Select(y => y.PrimaryKeyName)).Where(x => x.IsNullOrWhiteSpace() == false).ToList(); // Add valid and invalid foreign key differences to the result object // We'll need to do invariant contains with case insensitivity because foreign key, primary key is not standardized @@ -258,10 +253,8 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install } } - //Foreign keys: - - IEnumerable validForeignKeyDifferences = - foreignKeysInDatabase.Intersect(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase); + // Foreign keys: + IEnumerable validForeignKeyDifferences = foreignKeysInDatabase.Intersect(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase); foreach (var foreignKey in validForeignKeyDifferences) { if (foreignKey is not null) @@ -270,30 +263,23 @@ namespace Umbraco.Cms.Infrastructure.Migrations.Install } } - IEnumerable invalidForeignKeyDifferences = - foreignKeysInDatabase.Except(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase) - .Union(foreignKeysInSchema.Except(foreignKeysInDatabase, - StringComparer.InvariantCultureIgnoreCase)); + IEnumerable invalidForeignKeyDifferences = foreignKeysInDatabase.Except(foreignKeysInSchema, StringComparer.InvariantCultureIgnoreCase) + .Union(foreignKeysInSchema.Except(foreignKeysInDatabase, StringComparer.InvariantCultureIgnoreCase)); foreach (var foreignKey in invalidForeignKeyDifferences) { result.Errors.Add(new Tuple("Constraint", foreignKey ?? "NULL")); } - - //Primary keys: - - //Add valid and invalid primary key differences to the result object - IEnumerable validPrimaryKeyDifferences = - primaryKeysInDatabase!.Intersect(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)!; + // Primary keys: + // Add valid and invalid primary key differences to the result object + IEnumerable validPrimaryKeyDifferences = primaryKeysInDatabase!.Intersect(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)!; foreach (var primaryKey in validPrimaryKeyDifferences) { result.ValidConstraints.Add(primaryKey); } - IEnumerable invalidPrimaryKeyDifferences = - primaryKeysInDatabase!.Except(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)! - .Union(primaryKeysInSchema.Except(primaryKeysInDatabase, - StringComparer.InvariantCultureIgnoreCase))!; + IEnumerable invalidPrimaryKeyDifferences = primaryKeysInDatabase!.Except(primaryKeysInSchema, StringComparer.InvariantCultureIgnoreCase)! + .Union(primaryKeysInSchema.Except(primaryKeysInDatabase, StringComparer.InvariantCultureIgnoreCase))!; foreach (var primaryKey in invalidPrimaryKeyDifferences) { result.Errors.Add(new Tuple("Constraint", primaryKey)); diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs index 14b42dc92c..9739c9a295 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ExternalLoginRepository.cs @@ -48,7 +48,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .ForUpdate(); // deduplicate the logins - logins = logins.LegacyDistinctBy(x => x!.ProviderKey + x.LoginProvider).ToList(); + logins = logins.DistinctBy(x => x.ProviderKey + x.LoginProvider).ToList(); var toUpdate = new Dictionary(); var toDelete = new List(); @@ -241,7 +241,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .ToDictionary(x => x.LoginProvider, x => x.Id); // deduplicate the tokens - tokens = tokens.LegacyDistinctBy(x => x!.LoginProvider + x.Name).ToList(); + tokens = tokens.DistinctBy(x => x.LoginProvider + x.Name).ToList(); var providers = tokens.Select(x => x.LoginProvider).Distinct().ToList(); diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs index 0e2e9914a8..f94ffe03a3 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/MemberGroupRepository.cs @@ -183,7 +183,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .Where(x => x.Member == memberId); return Database.Fetch(sql) - .LegacyDistinctBy(dto => dto!.NodeId) + .DistinctBy(dto => dto.NodeId) .Select(x => MemberGroupFactory.BuildEntity(x)); } @@ -200,7 +200,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .Where("cmsMember.LoginName=@loginName", new { loginName = username }); return Database.Fetch(sql) - .LegacyDistinctBy(dto => dto!.NodeId) + .DistinctBy(dto => dto.NodeId) .Select(x => MemberGroupFactory.BuildEntity(x)); } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs index 7fce3581d1..106d1c906f 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs @@ -284,7 +284,7 @@ SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0 protected override IEnumerable PerformGetByQuery(IQuery query) { var dtos = GetDtosWith(sql => new SqlTranslator(sql, query).Translate(), true) - .LegacyDistinctBy(x => x!.Id) + .DistinctBy(x => x.Id) .ToList(); var users = new IUser[dtos.Count];