.net – LinqToSQL选择和选择对加入[已关闭]

选择和选择是否适合加盟?

我想知道的原因是因为我使用LinqPad,在一个部分有评论说:

// Note: before delving into this section,make sure you've read the preceding two
// sections: Select and SelectMany. The Join operators are actually unnecessary
// in LINQ to sql,and the equivalent of sql inner and outer joins is most easily
// achieved in LINQ to sql using Select/SelectMany and subqueries!

然而,在其他部分,它清楚地表明,联接更快(至少对于LinqPad中给出的示例),对我来说,它更容易在我的头脑中可视化.

也许我是误会,因为我只是看代码示例,而不是这本书,但我看到其他人建议选择和选择连接以及连接.

解决方法

Wayward Weblog有关于此事的 this to say. Join使用一组明确的参数来加入一个特定的键,并允许左右外连接. SelectMany执行一个 monadic bind,通常会导致内部连接或交叉连接.由于LINQ本质上是.NET中功能编程的实现,所以SelectMany是更自然的表达方式;然而,Join的显式设置可能导致更快的操作.

至于首选,我觉得你最清楚的是最好的. C# version of 101 LINQ Samples包括Join,但是VB list显示了在不同场景中使用的Join和SelectMany.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...