linq中的子查询

时间:2009-08-04 09:52:47

标签: c# sql linq-to-sql subquery join

到目前为止,我已经尝试了几天在LINQ中“翻译”这个查询并没有成功。你能帮我吗?我还要感谢一些解释,以便从中学到一些东西。

以下是T-SQL查询:

SELECT R.ResourceID, R.DefaultValue
FROM Resources as R
JOIN
    (SELECT [t0].[NameResourceID] AS [ResourceID]
    FROM [dbo].[Sectors] AS [t0]
    LEFT OUTER JOIN [dbo].[LocalizedResources] AS [t1] ON [t0].[NameResourceID] = [t1].[ResourceID] and [t1].[LanguageID] = 2
    WHERE t1.Value IS NULL)  AS subQ 

ON R.ResourceID = subQ.ResourceID

感谢的

1 个答案:

答案 0 :(得分:0)

尝试类似的东西:

from r in db.Resources
join subQ in (from t0 in db.Sectors
              join t1 in db.LocalizedResources on t0.NameResourceID equals t1.ResourceID
              where t1.LanguageId
              && t1.Value == null
              select new { ResourceID = t0.NameResourceID }) on r.ResourceID equals subQ.ResourceID
select new { r.ResourceId, r.DefaultValue };