我想将以下SQL查询转换为LINQ
SELECT a.*
FROM campaign_newslettersubscriber_track a
INNER JOIN (SELECT DISTINCT campaignid,
Min(id) AS id
FROM campaign_newslettersubscriber_track
GROUP BY campaignid) AS b
ON a.campaignid = b.campaignid
AND a.id = b.id
答案 0 :(得分:0)
var subquery = from c in objectContext.campaign_newslettersubscriber_track
group c by c.campaignid into g
select new
{
id = g.Min(x => x.campaignid),
campaignId = g.Key
};
var n = from c in objectContext.campaign_newslettersubscriber_track
join cin in subquery.Distinct() on c.campaignid equals cin.campaignId
select c;
答案 1 :(得分:0)