Skip to content

Commit

Permalink
Make sure to use OrderBy before Take
Browse files Browse the repository at this point in the history
This silences the warning about using a row limiting operator on an
unordered data set.
  • Loading branch information
veloek committed Sep 5, 2024
1 parent 8fb0af3 commit 6f0c15c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Tevling/Data/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
e => e.HasOne<Athlete>().WithMany().HasForeignKey(e => e.FolloweeId),
e => e.HasOne<Athlete>().WithMany().HasForeignKey(e => e.FollowerId));

modelBuilder.Entity<Athlete>()
.Property(a => a.Created)
.HasConversion(new DateTimeOffsetToBinaryConverter());

modelBuilder.Entity<Challenge>()
.HasOne(c => c.CreatedBy);

Expand Down
1 change: 1 addition & 0 deletions Tevling/Services/AthleteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public async Task<Athlete[]> GetSuggestedAthletesToFollowAsync(int athleteId, Ca
.Except(followedAthleteIds)
.Contains(a.Id) &&
a.Id != athleteId)
.OrderBy(a => a.Created)
.Take(5)
.ToArrayAsync(ct);

Expand Down

0 comments on commit 6f0c15c

Please sign in to comment.