Hacker News new | ask | show | jobs
by chrisb 5878 days ago
This is not quite correct.

The SQL generated in this case depends on the return type of GetThings(). If it returns an IEnumerable<> then it is indeed a terrible thing to do, but if it returns an IQueryable<> then the SQL will be a SELECT COUNT() query, and no objects will be created.

Care does have to be taken when writing this sort of code!