I want to convert following sql query to linq.
This is what I'm trying to convert
SELECT IH.ID, IH.InvNo, IH.PaymentStatus, SUM(TotalAmount) -
(SELECT SUM(Amount) FROM Student WHERE InvNo=bh.InvNo) AS CollectableAmount
FROM InvoiceHeader AS IH
INNER JOIN InvoiceDetail AS ID ON IH.ID=BD.BillId
WHERE IH.StudentID=0103 AND IH.PaymentStatus<>1
GROUP BY IH.ID, IH.InvNo, IH.PaymentStatus
I tried like this but I don't know how to get sub query inside this linq
from ih in InvoiceHeaders
join bd in InvoiceDetails on ih.ID equals id.BillId
where bh.StudentID = 0103 && bh.PaymentStatus != 1
select new { ID = ih.ID, BillNumber = ih.BillNumber, PaymentStatus = ih.PaymentStatus })
It says that from is not valid inside this,
select new { ID = ih.ID, BillNumber = ih.BillNumber, PaymentStatus = ih.PaymentStatus, (from s in student) })