0
我想把SQL查詢複製到LINQ中。 任何人都可以幫忙嗎?將SQL查詢轉換爲LINQ查詢
SQL:
SELECT tblInvoice.lngID AS InvoiceID,
tblInvoice.dtTimeStamp AS InvoiceDate,
tblInvoice.strReference,
tblInvoice.fltTotalValue,
max(Project.ProjectID) AS ProjectID,
max(Project.ProjectName) AS ProjectName,
max(Project.Location) AS ProjectLocation
FROM tblInvoice INNER JOIN
tblInvoiceLine ON tblInvoice.lngID = tblInvoiceLine.lngInvoiceID
WHERE (tblInvoice.intStatus != 0)
AND (tblInvoice.lngPersonID = @PersonID)
GROUP BY tblInvoice.lngID, tblInvoice.dtTimeStamp, strReference, fltTotalValue
ORDER BY tblInvoice.lngID DESC
LINQ至今:
問題的var invoices = from inv in db.TblInvoices
join invLine in db.TblInvoiceLines on inv.LngID equals invLine.LngInvoiceID
where inv.IntStatus != 0
where inv.LngPersonID == personID
group inv by new {inv.LngID,inv.DtTimeStamp,inv.StrReference,inv.FltTotalValue} into newInv
的是,我想要做一個
select new Invoice(){
}
,並建立我的自定義發票的對象,但,我無法看到newInv中的任何屬性。
任何人都可以建議嗎?
感謝那個喬恩我昨天有點腦凍結了。 – DazManCat 2010-09-17 09:13:30
當然,其他選項是做一個簡單的LINQ查詢,然後做一個invoices.GroupBy(x => new {x.InvoiceID,x.InvoiceDate,x.Reference,x.TotalValue}); – DazManCat 2010-09-17 09:24:47