请问有人可以帮助我将以下SQL的例子放到C#中的LINQ查询中,我使用的是.NET 4.0。
SELECT x.*
FROM [eBookAddict].[dbo].[UrlRecord] x
JOIN (SELECT t.Slug
FROM [eBookAddict].[dbo].[UrlRecord] t
GROUP BY t.Slug
HAVING COUNT(t.Slug) = 2) y ON y.Slug = x.Slug
非常感谢,
保
答案 0 :(得分:2)
from x in db.UrlRecord
join y in db.UrlRecord.GroupBy(rec => rec.Slug).Where(grp => grp.Count == 2)
on y.Key equals x.Slug
select x;