c# - Using multiple .Where() calls or && conditions for LinqToEntities queries -
are following 2 queries equivalent? if not equivalent, performs better? there way can see sql output of queries?
var query1 = items.where(i => i.enabled == true).where(i => i.name == "bob"); var query2 = items.where(i => i.enabled == true && i.name == "bob");
as andrew says, 2 options equivalent. 1 practically useful difference can generate conditions in where
clause programmatically. example if wanted exclude names:
var query = items; for(string name in excluded) query = query.where(i => i.name != excluded);
this cannot done when writing query using &&
operator.
Comments
Post a Comment