Skip to content

Commit

Permalink
fix: .Min()Order().FirstOrDefault()
Browse files Browse the repository at this point in the history
Change `.Min()` to `.Order().FirstOrDefault()` so it won't throw and instead return null when the sequence is empty.
  • Loading branch information
revam committed Feb 13, 2025
1 parent 8a27af2 commit 1c635c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Shoko.Server/Providers/TMDB/TmdbMetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,8 @@ private async Task DownloadSeasonImages(int seasonId, int showId, int seasonNumb
var releasedAt = _tmdbEpisodes.GetByTmdbSeasonID(seasonId)
.Select(o => o.AiredAt)
.WhereNotNull()
.Min();
.Order()
.FirstOrDefault();
await _imageService.DownloadImagesByType(season.PosterPath, releasedAt, images.Posters, ImageEntityType.Poster, ForeignEntityType.Season, seasonId, settings.TMDB.MaxAutoPosters, languages, forceDownload);
}

Expand Down

1 comment on commit 1c635c7

@Rand-Random
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI
there is a method for this case

DefaultIfEmpty()
https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.defaultifempty?view=net-8.0

so you could say DefaultIfEmpty().Min()

Please sign in to comment.