加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

vb.net – LINQ中的Equals和=有什么区别?

发布时间:2020-12-17 07:17:56 所属栏目:百科 来源:网络整理
导读:LINQ中Equals和=之间有什么区别? Dim list As List(Of Foo) = (From a As Foo In FooList _Join b As Bar In BarList _On a.Something = b.Something _Select a).ToList() 与 Dim list As List(Of Foo) = (From a As Foo In FooList _Join b As Bar In BarL
LINQ中Equals和=之间有什么区别?

Dim list As List(Of Foo) = (From a As Foo In FooList _
Join b As Bar In BarList _
On a.Something = b.Something _
Select a).ToList()

Dim list As List(Of Foo) = (From a As Foo In FooList _
Join b As Bar In BarList _
On a.Something Equals b.Something _
Select a).ToList()

解决方法

从 The Moth引用马特沃伦

“The reason C# has the word ‘equals’
instead of the ‘==’ operator was to
make it clear that the ‘on’ clause
needs you to supply two separate
expressions that are compared for
equality not a single predicate
expression. The from-join pattern maps
to the Enumerable.Join() standard
query operator that specifies two
separate delegates that are used to
compute values that can then be
compared. It needs them as separate
delegates in order to build a lookup
table with one and probe into the
lookup table with the other. A full
query processor like SQL is free to
examine a single predicate expression
and choose how it is going to process
it. Yet,to make LINQ operate similar
to SQL would require that the join
condition be always specified as an
expression tree,a significant
overhead for the simple in-memory
object case.”

编辑

后来在文章中.

更新:Visual Basic团队的Vladimir Sadov告诉我,VB也使用Equals,原因几乎相同.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读