0
我写了一些LINQ来模拟SQL GroupBy语句(请参见下文)。不过,在做群组之前,我也只需要考虑最后的10个设置ID。我想我会用Take来做到这一点,但是在我的陈述中,正确的语法是什么?LINQ采用语法
var settings2 = from s in dc.SystemSettings
where s.campConfig.campaignType == campType
&& s.campId != campId
&& s.settingKey == ticket.setting.Key
orderby s.settingId descending
group s by s.settingValue
into grp
select new
{
SettingValue = grp.Key,
SettingCount = grp.Select(x => x.settingValue).Count()
};
能否请您缩进代码更好地使其更具可读性? – 2012-04-12 07:11:03