Forgot that LastOrDefault needs an OrderBy

This commit is contained in:
barelyprofessional
2026-01-02 21:28:59 -06:00
parent b0473d68ab
commit 4ccb6b7865

View File

@@ -86,6 +86,7 @@ public class BlackjackCommand : ICommand
// Check for existing incomplete blackjack game
var existingGame = await _dbContext.Wagers
.OrderBy(x => x.Id)
.LastOrDefaultAsync(w => w.Gambler.Id == gambler.Id &&
w.Game == WagerGame.Blackjack &&
!w.IsComplete && w.GameMeta != null,
@@ -157,6 +158,7 @@ public class BlackjackCommand : ICommand
// Update wager ID in game state
var createdWager = await _dbContext.Wagers
.OrderBy(x => x.Id)
.LastOrDefaultAsync(
w => w.Gambler.Id == gambler.Id && w.Game == WagerGame.Blackjack && !w.IsComplete && w.GameMeta != null,
cancellationToken: ctx) ?? throw new InvalidOperationException();
@@ -200,6 +202,7 @@ public class BlackjackCommand : ICommand
// Find active game
var activeWager = await _dbContext.Wagers
.OrderBy(x => x.Id)
.LastOrDefaultAsync(w => w.Gambler.Id == gambler.Id &&
w.Game == WagerGame.Blackjack &&
!w.IsComplete && w.GameMeta != null, cancellationToken: ctx);