I want to be able to pull the last invoice containing a product in a category
Category->Product->Invoice
(from p as Product in cat
where p.InvoiceList.Where(function(o) o.InvoiceDate >= MAX_ONE)
select p.InvoiceList.Where(function(o) o.InvoiceDate >= MAX_ONE)
).FirstOrDefault()
I just can’t seem to wrap my head about how to get this done.
EDIT: a sample SQL statement that would accomplish my goal. If only I could translate it…
SELECT TOP 1 i.InvoiceID, i.InvoiceDate, i.TotalAmount
FROM Category as c INNER JOIN
Product as p ON p.categoryID = c.categoryID INNER JOIN
InvoiceProducts as ip ON ip.productID = p.productID INNER JOIN
Invoice as i ON ip.InvoiceID = i.InvoiceID
WHERE c.categoryID = 3
ORDER BY InvoiceDate DESC
1 Answer