.net – Does ‘And’ vs ‘AndAlso’ matter with linq in vb.net

linqvb.net

Does it matter if you are using 'And' or 'AndAlso' in linq queries in vb.net? I know in normal operations 'AndAlso' is short circuit and so will often be faster, but I don't know if that carries over into linq queries. Does it matter if the linq query is against a database or against an in memory collection?

Best Solution

For LINQ to object queries, it would definitely matter. For other LINQ providers, it depends on the provider itself. At the expression tree level, they are different but the provider might choose to translate/run it the same way. For instance, there's no equivalent notion in SQL so LINQ to SQL translates them to identical SQL.

Related Question