第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Linq:如何在查詢語法中編寫 Any ?

Linq:如何在查詢語法中編寫 Any ?

C#
弒天下 2023-12-17 09:57:34
IEnumerable<Gruppe> cand = (IEnumerable<Gruppe>)populations.Where(                             x => !x.Attributes.Any(                                  y => y.GetType() == typeof(Arbeit)                               )                           );我想知道如何用查詢語法編寫上述內(nèi)容,但由于 Any 方法而被絆倒。
查看完整描述

3 回答

?
慕沐林林

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個贊

查詢語法中沒有與 Any 等效的內(nèi)容。所以你能做的最好的事情是:


IEnumerable<Gruppe> cand =

   from population in populations

   where !population.Attributes.Any(y => y.GetType() == typeof(Arbeit))

   select population

(我假設(shè)沒有必要強(qiáng)制轉(zhuǎn)換為 IEnumerable<Gruppe>。如果該假設(shè)錯誤,您需要將其添加回來。)


查看完整回答
反對 回復(fù) 2023-12-17
?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個贊

我喜歡斯維克的回答。


另一種說法是這樣的:


IEnumerable<Gruppe> cand = 

    from population in populations

    where ( from attribute in population.Attributes

        where attribute.GetType() == typeof(Arbeit)

        select true).Any() == false

    select population


查看完整回答
反對 回復(fù) 2023-12-17
?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個贊

Any 可以重構(gòu),但您仍然需要 Count。


var cand = from population in populations

           let attributeCount = population.Attributes.Count

           let validAttributeCount = (

               from attribute in population.Attributes

               where attribute.GetType() != typeof(Arbeit)

               select attribute

           ).Count()

           where attributeCount == validAttributeCount

           select population;


查看完整回答
反對 回復(fù) 2023-12-17
  • 3 回答
  • 0 關(guān)注
  • 252 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號