I am studying LINQ, and particularly LINQ to SQL on MSDN and came across this example, which, unless there is some clever magic under the hood, looks like a case of extreme sacrifice of computing resources over code readability.
int highScoreCount =
(from score in scores
where score > 80
select score)
.Count();
Someone please tell me that this query does not load all the scores in the list just to get their count. Or even not the scores over 80.
And if this is the case for this particular query , is there a was to change it in order to avoid loading the complete list of scores? like "select (count) score".
Thanks.
EDIT: I apologise for being lazy and not looking up a way to view generated SQL first. I found that the easiest way to do that is use LinqPad