我希望supplierCosts能够加入。目前没有记录..读取供应商成本中的零记录,但我仍然希望显示其他联接的数据。我究竟做错了什么 ?如果在SupplierCosts中有记录,那么它只返回数据,然后只记录该表中的记录。
var query = (from popco in db.prcOpcoes
join p in db.products on popco.productID equals p.productID
join s in db.suppliers on popco.supplierNumber equals s.supplierNumber
join sc in db.SupplierCosts on new { s.supplierNumber, productId = p.productID } equals new { supplierNumber = sc.SupplierNumber, productId = sc.ProductID } into data
from x in data.DefaultIfEmpty()
where x.SupplierNumber == suppliernumber && popco.opcoID == opco
select new ProductItem() { ProductID = p.productID, Description = p.division, FOB = x.FOB, Freight = x.Freight, DeliveredPrice = x.DeliveredPrice, Comments = x.Comments, Submitted = x.SubmittedDate });
return query.ToList();
答案 0 :(得分:1)
在发布的表达式中x
被确定为SupplierCost
因此,where子句
where x.SupplierNumber == suppliernumber
将消除"行"如果他们没有出现在SupplierCost
请改为尝试:
where s.SupplierNumber == suppliernumber