Using the above answers, I did some tests and found interesting things regarding runtime:
var query1 = Titles
.Where(t => t.ReleaseYear == 2007)
.Select(t => new {t.Name});
query1.Dump();
var query2 = Titles
.Where(t => t.ReleaseYear == 2007)
.AsEnumerable()
.Select(t => t.Name);
query2.Dump();
Do I understand correctly that in request 1 only the "Name" property is returned? Whereas in query 2, the "AsEnumerable ()" method returns an object with all property values, hence a longer execution time?
source
share