Linq中的左外连接
我知道有很多关于这方面的帖子,但都是关于具体问题的,我不知道什么是左,什么是右,什么都不知道 我有两张单子:左和右。我需要选择左侧所有不在右侧的元素Linq中的左外连接,linq,outer-join,Linq,Outer Join,我知道有很多关于这方面的帖子,但都是关于具体问题的,我不知道什么是左,什么是右,什么都不知道 我有两张单子:左和右。我需要选择左侧所有不在右侧的元素 List<T> left = GetLeft(); List<T> right = GetRight(); IEnumerable result = // Have no idea List left=GetLeft(); List right=GetRight(); IEnumerable result=//我不知道
List<T> left = GetLeft();
List<T> right = GetRight();
IEnumerable result = // Have no idea
List left=GetLeft();
List right=GetRight();
IEnumerable result=//我不知道
我该怎么做?听起来根本不像是加入。。。这听起来像:
var result = left.Except(right);
我找到了一个解决办法 查找所有未购买的客户: SQL: 林克:
看起来就是这样,我太习惯SQL了
Select c.Name from Customers c
Left Outer Join Purchases p on c.customerid=p.customerid
where p.price is null
from c in Customers
join p in Purchases on c.customerid=p.customerid into custPurchases
from cp in custPurchases.DefaultIfEmpty()
where cp==null
select new
{
cc.Name
}