From 6f0c15c43e344bddf9ea46165384cdc547627974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vegard=20L=C3=B8kken?= Date: Fri, 6 Sep 2024 00:18:41 +0200 Subject: [PATCH] Make sure to use `OrderBy` before `Take` This silences the warning about using a row limiting operator on an unordered data set. --- Tevling/Data/DataContext.cs | 4 ++++ Tevling/Services/AthleteService.cs | 1 + 2 files changed, 5 insertions(+) diff --git a/Tevling/Data/DataContext.cs b/Tevling/Data/DataContext.cs index 238ce6f..c0bd8b9 100644 --- a/Tevling/Data/DataContext.cs +++ b/Tevling/Data/DataContext.cs @@ -44,6 +44,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) e => e.HasOne().WithMany().HasForeignKey(e => e.FolloweeId), e => e.HasOne().WithMany().HasForeignKey(e => e.FollowerId)); + modelBuilder.Entity() + .Property(a => a.Created) + .HasConversion(new DateTimeOffsetToBinaryConverter()); + modelBuilder.Entity() .HasOne(c => c.CreatedBy); diff --git a/Tevling/Services/AthleteService.cs b/Tevling/Services/AthleteService.cs index 0b98ed6..090e21a 100644 --- a/Tevling/Services/AthleteService.cs +++ b/Tevling/Services/AthleteService.cs @@ -219,6 +219,7 @@ public async Task GetSuggestedAthletesToFollowAsync(int athleteId, Ca .Except(followedAthleteIds) .Contains(a.Id) && a.Id != athleteId) + .OrderBy(a => a.Created) .Take(5) .ToArrayAsync(ct);