vb.net中的linq对"And"和"AndAlso"有影响吗? [英] Does 'And' vs 'AndAlso' matter with linq in vb.net?

查看:85
本文介绍了vb.net中的linq对"And"和"AndAlso"有影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vb.net的linq查询中使用'And'或'AndAlso'是否重要?我知道在正常操作中"AndAlso"是短路的,因此通常会更快,但是我不知道这是否会延续到linq查询中. linq查询是针对数据库还是针对内存中集合,这有关系吗?

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?

推荐答案

对于LINQ到对象的查询,这绝对重要.对于其他LINQ提供程序,它取决于提供程序本身.在表达式树级别上,它们不同,但是提供程序可能选择以相同的方式来翻译/运行它.例如,SQL中没有等效的概念,因此LINQ to SQL会将它们转换为相同的SQL.

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.

这篇关于vb.net中的linq对"And"和"AndAlso"有影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆