LINQ:如何在LINQ语句中执行内联select语句?

时间:2011-06-24 18:06:12

标签: sql vb.net linq

我有以下SQL:

SELECT 
    *, 
    (SELECT COUNT(*) FROM WebOrder_URLHistory WHERE WebOrder_URLHistory.LeadID = Leads.LeadID) AS Sales
FROM 
    Leads

我想把它(select count语句)放在这个LINQ语句中,这样我就可以在我的linq语句中得到销售计数:

Dim TheLeads = (From L In DB.Leads Where L.IsDeleted = False Select L).ToList()

这可以在LINQ中完成吗?

1 个答案:

答案 0 :(得分:6)

您可以撰写Select L, L.UrlHistory.Count()