linq 左连接生成的sql带有or条件。看代码

AlenOU AlenOU 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
linq代码:
var stockQuery = from od in db.sto_StockInOrderDetail.Where(ox => ox.DetailType == 2)
join o in db.sto_StockInOrder.Where(x => x.BusinessBillID == "305" && x.State == 200) on od.StockInID equals o.StockInID
select new { ProductID =od.ProductID, StockInID =o.StockInID, SupplierID =o.SupplierID};

var querydata = from q in query.Where(xq=>xq.ProductID !="")
join b in stockQuery.Distinct() on q.ProductID equals b.ProductID
into temp
from tempD in temp.DefaultIfEmpty()
join s in db.core_Good on q.SKU equals s.SKU
select new { record = q,good = s,sup = tempD.SupplierID, PurchaseCode = tempD.StockInID };

跟踪出来的sql:


怎么会多个or条件呢?有这个。导致sql查询很慢。去掉这个or,查询就很快出来的!
求大神指点,怎么让左连接不生成这个or条件。
...全文
评论 8
收藏 已收藏
分享
返回顶部
AlenOU
LINQ 8,492 成员 4,736 内容