linq join 两个表部分字段相同结果合并查询

比才 比才 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

我想查询CustomerAccountLogs里面的所有数据通过SendOrderId关联发货明细表的数据

from a in CustomerAccountLogs
join b in (
from s in SendOrders
join sd in SendOrderLines on s.Id equals sd.SendOrderId
select new
{
SendOrderId = sd.SendOrderId,
ProductName = sd.OrderLine.ProductName,
UnitName = sd.OrderLine.UnitName,
Price = sd.OrderLine.Price,
Amount = sd.OrderLine.Price * sd.OrderLine.Count
}
) on a.SendOrderId equals b.SendOrderId
where a.AccountId == 2
select new
{
a.SendOrderId,
a.OperationNumber,
a.OperationType,
b.ProductName,
b.UnitName,
b.Price,
b.Amount
}

这是目前查出来的结果 但是只查出来了 CustomerAccountLogs 表SendOrderId字段有值的数据 我想把SendOrderId字段等于空的也查出来显示在结果集里面 如何处理
这个是我目前的结果


最终要的效果是 下图
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
比才
C# 111,130 成员 642,541 内容