Reputation: 28131
In Entity Framework, is there any performance cost of doing this...
var businesses = dbContext.Businesses.Where(x => x.Name.ToLower().StartsWith(name) && businessTypes.Contains(x.Type));
... versus this?
var businesses = dbContext.Businesses.Where(x => x.Name.ToLower().StartsWith(name)).Where(x => businessTypes.Contains(x.Type));
I prefer to do the latter since it's easier to read, but not if there's a serious performance hit on the generated SQL.
Upvotes: 0
Views: 46
Reputation: 160922
No there is no performance cost - the EF Linq provider maps both to the same SQL query. I personally find the first version much more readable though.
Upvotes: 3