diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 0b246effb..f051e3adb 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -483,12 +483,11 @@ namespace NzbDrone.Common.Disk return mounts.Where(drive => drive.RootDirectory.PathEquals(path) || drive.RootDirectory.IsParentPath(path)) - .OrderByDescending(drive => drive.RootDirectory.Length) - .FirstOrDefault(); + .MaxBy(drive => drive.RootDirectory.Length); } catch (Exception ex) { - Logger.Debug(ex, string.Format("Failed to get mount for path {0}", path)); + Logger.Debug(ex, $"Failed to get mount for path {path}"); return null; } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 8b509c2a3..80e0a3313 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -239,8 +239,7 @@ namespace NzbDrone.Core.Download.Pending var movieReleases = GetPendingReleases(movieId); return movieReleases.Select(r => r.RemoteMovie) - .OrderByDescending(p => p.Release.AgeHours) - .FirstOrDefault(); + .MaxBy(p => p.Release.AgeHours); } private List GetPendingReleases() diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index e90888925..118df0f1b 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -37,9 +37,7 @@ namespace NzbDrone.Core.History public MovieHistory MostRecentForDownloadId(string downloadId) { - return FindByDownloadId(downloadId) - .OrderByDescending(h => h.Date) - .FirstOrDefault(); + return FindByDownloadId(downloadId).MaxBy(h => h.Date); } public List FindByDownloadId(string downloadId) @@ -90,9 +88,7 @@ namespace NzbDrone.Core.History public MovieHistory MostRecentForMovie(int movieId) { - return Query(x => x.MovieId == movieId) - .OrderByDescending(h => h.Date) - .FirstOrDefault(); + return Query(x => x.MovieId == movieId).MaxBy(h => h.Date); } public List Since(DateTime date, MovieHistoryEventType? eventType) diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs index b9c42fde4..c6bca04aa 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -182,9 +182,7 @@ namespace NzbDrone.Core.RootFolders public string GetBestRootFolderPath(string path) { - var possibleRootFolder = All().Where(r => r.Path.IsParentPath(path)) - .OrderByDescending(r => r.Path.Length) - .FirstOrDefault(); + var possibleRootFolder = All().Where(r => r.Path.IsParentPath(path)).MaxBy(r => r.Path.Length); if (possibleRootFolder == null) {