Linq to sql linqtake语法

Linq to sql linqtake语法,linq-to-sql,Linq To Sql,我编写了一些LINQ来模拟SQLGroupBy语句(见下文)。不过,我也只需要考虑最后10个设置ID之前,我的小组。我想我会用Take来做这个,但是我的语句中正确的语法是什么 var settings2 = from s in dc.SystemSettings where s.campConfig.campaignType == campType && s.campId != campId

我编写了一些LINQ来模拟SQLGroupBy语句(见下文)。不过,我也只需要考虑最后10个设置ID之前,我的小组。我想我会用Take来做这个,但是我的语句中正确的语法是什么

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()
                };

我会这样做

var settings2 = from sOuter in 
    (from s in dc.SystemSettings
    where s.campConfig.campaignType == campType
      && s.campId != campId
      && s.settingKey == ticket.setting.Key
    orderby s.settingId descending
    select s).Take(10)
    group sOuter by sOuter.settingValue
    into grp
    select new
    {
      SettingValue = grp.Key,
      SettingCount = grp.Select(x => x.settingValue).Count()
    };

你能把你的代码缩进一点,让它更可读吗?