简体   繁体   English

在哪里加入。 哪个更好用

[英]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.

相关问题 MemoryStream VS FileStream在Webservice中使用哪个更好地进行GZipStream解压缩? - MemoryStream VS FileStream which one is better to use in Webservice for GZipStream decompress? C#JOIN与Sql Server中的存储过程,哪一个带来更好的性能? - C# JOIN vs. Stored Procedure in Sql Server, Which one brings a better performance? Parallel vs Await vs Result - 哪个更适合延迟执行 - Parallel vs Await vs Result - which one is better for deferred execution 循环还是递归方法? 哪个更好用? - Loop or Recursive method? Which one is better to use? 哪一个更好用,为什么用c# - Which one is better to use and why in c# SqlDataReader vs SqlDataAdapter:哪一个具有更好的返回DataTable的性能? - SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable? XPath vs DeSerialization:哪一个在读取操作方面性能更好 - XPath vs DeSerialization: which one is better in performance for read operations 哪个更好处理版本控制? XmlSerializer与DataContractSerializer? - Which One Better Handles Versioning? XmlSerializer vs. DataContractSerializer? ASP.NET vs SharePoint - 哪一个更适合Web开发人员? - ASP.NET vs SharePoint - which one is better for web developers? 哪个对性能更好:foreach()tatement或Where()查询? - Which one is better for performance: foreach()tatement or Where() query?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM