首页 > 代码库 > linq 左连接

linq 左连接

var list = (from item in vall
join item3 in v1 on new { item.FItemID, item.FAuxPropID } equals new { item3.FItemID, item3.FAuxPropID } into stockqty
from itemstock in stockqty.DefaultIfEmpty()
select new ICStockBillEntry
{
FAuxPropID = item.FAuxPropID,
FSecQty = itemstock == null ? item.FSecQty : item.FSecQty - itemstock.FSecQty,
FQty = itemstock == null ? item.FQty : item.FQty - itemstock.FQty,
FUnitID = item.FUnitID,
FSecCoefficient=item.FSecCoefficient,
FUnitName = item.FUnitName,
FNumber = item.FNumber,
FItemName = item.FItemName,
FModel = item.FModel.Replace(item.FItemName,""),
FAuxPropName = item.FAuxPropName,
FAuxUnitName = item.FAuxUnitName,
FItemID = item.FItemID,
FMTONo = item.FMTONo,
FPrintCount = 1,
}).Where(n=>n.FQty>0).ToList();

linq 左连接