Linq左外连接 [英] Linq left outer join
本文介绍了Linq左外连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最终需要的是通用函数,它将使用两个datatable和2个tablekey并返回Joined datatable.所以这是我要解决的第一步.
I ultimately what I needed is generic function which would take two datatable and and 2 tablekeys and return Joined datatable. So here is my first step to solve it.
如何在VB中编写以下T-SQL示例的Linq示例?
How Can I write Linq example of following T-SQL example in VB?
SELECT * FROM
Table1
LEFT OUTER JOIN
Table2
ON Table1.key = Table2.key
推荐答案
会是这样的:
Dim JoinedResult = From t1 In Table1
Group Join t2 In Table2
On t1.key Equals t2.key
Into RightTableResults = Group
From t2 In RightTableResults.DefaultIfEmpty
Select t1.Prop1,
t2.Prop2
我已经不是VB了,但是我认为这可以.
I'm not a VB guy (anymore), but I think this would work.
这篇关于Linq左外连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文