当内部具有子查询时如何将SQL转换为LINQ选择作为选择器

时间:2019-07-03 09:36:01

标签: sql linq

我想将以下SQL查询转换为linq。

这就是我要转换的东西

from BeautifulSoup import BeautifulSoup
import urllib2
url= 'http://www.awgp.org/about_us'
openurl=urllib2.urlopen(url)
soup = BeautifulSoup(openurl.read())
for a in soup.findAll('a'):
  print (a.text, a.get('href'))

我尝试过这样,但我不知道如何在此linq中获取子查询

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

它表示from无效,

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 })

0 个答案:

没有答案