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?
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.
Whether or not to use And vs. AndAlso is very dependent on the context of the usage. However it's almost always preferable to use AndAlso over And.
The short circuit quality of AndAlso will carry over to LINQ queries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With