From 2ba4740fe95c1f5033764b25bdcac7eb2767a9c0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 21 Sep 2024 21:35:43 -0400 Subject: [PATCH] Fix the EFCore warning for unordered queryables. Will need to revisit this --- .../Authority/Core/AuthorityInvokerBase{TAuthority}.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Authority/Core/AuthorityInvokerBase{TAuthority}.cs b/src/Tgstation.Server.Host/Authority/Core/AuthorityInvokerBase{TAuthority}.cs index 0fe86fa146..f04293aecc 100644 --- a/src/Tgstation.Server.Host/Authority/Core/AuthorityInvokerBase{TAuthority}.cs +++ b/src/Tgstation.Server.Host/Authority/Core/AuthorityInvokerBase{TAuthority}.cs @@ -1,6 +1,8 @@ using System; using System.Linq; +using Tgstation.Server.Api.Models; + namespace Tgstation.Server.Host.Authority.Core { /// @@ -32,8 +34,14 @@ namespace Tgstation.Server.Host.Authority.Core IQueryable IAuthorityInvoker.InvokeTransformableQueryable(Func> authorityInvoker) { ArgumentNullException.ThrowIfNull(authorityInvoker); + + var queryable = authorityInvoker(Authority); + + if (typeof(EntityId).IsAssignableFrom(typeof(TResult))) + queryable = queryable.OrderBy(item => ((EntityId)(object)item).Id!.Value); // order by ID to fix an EFCore warning + var expression = new TTransformer().Expression; - return authorityInvoker(Authority) + return queryable .Select(expression); } }