Old post and this is largely opinion-based, but here's another consideration not mentioned above:
A SingleOrDefault
clause can't be followed by other terms like Select
because, as Patel notes above, it actually executes the query. For example say down the road you want to modify the query to return just the customer's name:
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.SingleOrDefault(cust => cust.Id == customerId && cust.CustomerType == (int)cusType)
.Select(cust=>cust.Name); //compile error
won't work, and you can't move the Select
clause to before the SingleOrDefault
because then the Id
and CustomerType
fields won't be visible to the lambda expression in SingleOrDefault
. Instead you'd need to add back the Where
clause first:
this.Storage.Customer.OfType<Preferred>()
.Include(b => b.Order)
.Where(cust => cust.Id == customerId && cust.CustomerType == (int)cusType)
.Select(cust=>cust.Name)
.SingleOrDefault();
Thus because the Where
clause often is necessary and always at least as good performance, it is probably good practice to always use it for consistency, readability, and maintainability.