On some code I have right now we are executing our LINQ to SQL queries like so:
db.Customers.Where(c => c.Name.StartsWith("A"))
.OrderBy(c => c.Name).Select(c => c.Name.ToUpper());
But a lot of examples I see, the Linq to SQL code is written like:
var query =
from c in db.Customers
where c.Name.StartsWith ("A")
orderby c.Name
select c.Name.ToUpper();
I am worried that we are fetching the whole table in the current code, and afterwards manipulating it locally, which from my point of view is not efficient compared to having the SQL server doing it.
Is the two examples equivalent or is there a difference?