我是linq的新手......我想知道我做得对..
这是我的代码......
var result = from a in ctx.ItemReceipts
join b in ctx.ItemReceiptStatusTypes on a.Status equals b.ItemReceiptStatusTypeID
join c in ctx.PurchaseOrders on a.ReferenceID equals c.PurchaseOrderID
into leftJoinItemReceipts
from d in leftJoinItemReceipts.DefaultIfEmpty()
where a.ItemReceiptID.Equals(ItemReceiptID)
select new
{
CItemReceiptID = a.ItemReceiptID,
CTransactionNumber = a.TransactionNumber,
CRemarks = a.Remarks,
CStatus = a.Status,
CStatusType = b.Description,
CReferenceID = a.ReferenceID,
CReferenceTypeID = a.ReferenceTypeID,
CTransactionDate = a.TransactionDate,
CDateReceived = a.DateReceived,
CTotalCost = a.TotalCost,
CPONumber = d.PONumber
};
它运行得很完美...但是我真的无法理解into
部分..我不知道它是否真的是一个左连接而是给了我想要的数据...它给了我所有的数据itemreceipts
即使他们与PurchaseOrder
....
我需要解释...更好的mysql和linq之间的比较...
答案 0 :(得分:0)
skipOnEmpty
这将在ItemReceipts和ItemReceiptStatusTypes上进行左连接,然后使用PurchaseOrders进行内连接