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