[英]where vs join. which one is better to use
Currently I'm running some code and got some question about this. 目前,我正在运行一些代码,对此有一些疑问。 Below are the code listings of two LINQ to Entites queries. 下面是两个LINQ to Entites查询的代码清单。
Code listing A: 代码清单A:
IQueryable list =
from tableProject in db.Project
select new {StaffInCharge = (
from tableStaff in db.Staff
where tableStaff.StaffId == tableProject.StaffInChargeId
select tableStaff.StaffName)};
Code listing B: 代码清单B:
IQueryable list =
from tableProjectin db.Project
join tableStaff in db.Staff
on tableProject.StaffInChargeId
equal tableStaff.StaffId
select new {StaffInCharge = tableStaff.StaffName};
What I want to figure out is which one will be better and faster if I have to select many column from many others table. 我想弄清楚的是,如果我必须从许多其他表中选择许多列,哪一种会更好,更快。
Thanks. 谢谢。
this is the comment from @Tim Schmelter 这是@Tim Schmelter的评论
"The article(actually my SO-Question) relates to LINQ-To-DataSet what is based on LINQ-To-Objects. Linq to SQL or Linq to Entities might be optimized by the DBMS in that way that a where clause has the same performance as a join." “这篇文章(实际上是我的SO问题)与LINQ-To-DataSet有关,它是基于LINQ-To-Objects的。DBMS可以优化Linq to SQL或Linq to Entities,使where子句具有相同的含义表演。”
and the link is Why is LINQ JOIN so much faster than linking with WHERE? 链接是为什么LINQ JOIN比与WHERE链接这么快? i think it is very useful. 我认为这非常有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.