亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

根據屬性從列表中刪除項目

根據屬性從列表中刪除項目

C#
夢里花落0921 2022-12-24 12:42:18
我有一個奇怪的情況,代碼行執行時間超過 5 分鐘,我不明白為什么:var cleansedTransactions = competitorTransactions.Where(i => !endedItemsLocal.Contains(i.ItemID)).ToList();進一步解釋:competitorTransactions - is a list of transactions which in this case contains 921 record inside it; endedItemsLocal - is an IEnumerable<string> - which in this case contains 8 records我在這里要做的是從“competitorTransactions”列表中刪除“endedItemsLocal”(IEnumerable) 中包含的所有項目。為什么執行需要 5-9 分鐘?如果這兩個集合包含數百萬條記錄,我可以說需要 9 分鐘,但只有 921 和 8,這讓我發瘋,我不明白為什么要花這么長時間?有人可以幫我嗎 ?:/
查看完整描述

1 回答

?
吃雞游戲

TA貢獻1829條經驗 獲得超7個贊

您不應該使用 IEnumerable,因為它是延遲加載的。使用 endedItemsLocal 的 ToArray 并使用該集合,這將分配一個集合,從而提高速度。



查看完整回答
反對 回復 2022-12-24
  • 1 回答
  • 0 關注
  • 76 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號