I have two lines of code, one is
AllItems().Where(c => c.Id== id)
.Select(d => new Quality(d.QualityType)).ToList();
and the other one
AllItems().Where(c => c.Id== id).ToList()
.Select(d => new Quality(d.QualityType)).ToList();
The only difference is on the second statement ToList()
is called after the Where
statement. The second statment works just fine.
On the first statement, the default parameterless constructor is hit instead of the constructor with the parameter. so the list is created but the objects in the list are initialized with default values rather than with the d.QualityType.
you can see the full source of the file in question at (Method: GetBestQualityInHistory)
https://github.com/kayone/NzbDrone/blob/master/NzbDrone.Core/Providers/HistoryProvider.cs
**Edit: After further investigation, this seems to be a SubSonic bug, if the Last ToList
is replaced by an OrderBy
subsonic throws an The construtor 'Void .ctor(NzbDrone.Core.Repository.Quality.QualityTypes, Boolean)' is not supported
.