【发布时间】:2010-06-10 12:02:23
【问题描述】:
基于这个问题: What is difference between Where and Join in linq?
我的问题如下:
以下两个语句是否存在性能差异:
from order in myDB.OrdersSet
from person in myDB.PersonSet
from product in myDB.ProductSet
where order.Persons_Id==person.Id && order.Products_Id==product.Id
select new { order.Id, person.Name, person.SurName, product.Model,UrunAdı=product.Name };
和
from order in myDB.OrdersSet
join person in myDB.PersonSet on order.Persons_Id equals person.Id
join product in myDB.ProductSet on order.Products_Id equals product.Id
select new { order.Id, person.Name, person.SurName, product.Model,UrunAdı=product.Name };
我总是使用第二个,因为它更清晰。
我现在的问题是,第一个比第二个慢吗? 它是否构建了一个笛卡尔积并在之后使用 where 子句对其进行过滤?
谢谢。
【问题讨论】:
标签: linq