From a3e9e87ea5cbb09e3b817390787048339e0a6fb0 Mon Sep 17 00:00:00 2001 From: Eddasol Date: Wed, 18 Oct 2023 16:34:25 +0200 Subject: [PATCH] Fix mission order --- backend/api/Services/SortingService.cs | 3 --- backend/api/Utilities/PagedList.cs | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/backend/api/Services/SortingService.cs b/backend/api/Services/SortingService.cs index 10bb9e5da..193032579 100644 --- a/backend/api/Services/SortingService.cs +++ b/backend/api/Services/SortingService.cs @@ -9,9 +9,6 @@ public class SortingService { public static void ApplySort(ref IQueryable missions, string orderByQueryString) where T : SortableRecord { - if (!missions.Any()) - return; - if (string.IsNullOrWhiteSpace(orderByQueryString)) { missions = missions.OrderBy(x => x.Name); diff --git a/backend/api/Utilities/PagedList.cs b/backend/api/Utilities/PagedList.cs index 7e84e31a9..ea78a816c 100644 --- a/backend/api/Utilities/PagedList.cs +++ b/backend/api/Utilities/PagedList.cs @@ -33,14 +33,8 @@ public static async Task> ToPagedListAsync( int pageSize ) { - // Adding order by constant value 1, which does not change order of rows - // but stops the runtime warning int totalCount = await source.CountAsync(); - List items; - if (source.Expression.Type is IOrderedQueryable) - items = await source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync(); - else - items = await source.OrderBy(x => 1).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync(); + var items = await source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync(); return new PagedList(items, pageNumber, pageSize, totalCount); } }