3 ms·
Uhg. Always defer materializing the query until you need it. If you are using LINQ against something like EF it changes how the SQL is generated. Consider va
by snarfy 14y ago
Uhg. Always defer materializing the query until you need it. If you are using LINQ against something like EF it changes how the SQL is generated.
Consider
var query = (from customer in context.Customers select customer).ToList().Where( c => c.Id == 3);
vs
var query = (from customer in context.Customers where customer.Id == 3 select customer);
The first LINQ query results in "SELECT * FROM customer". The WHERE clause is applied after the result set is returned. The second generates a real WHERE clause. The result set is filter on the server before being sent to the client.