[英]Error CS1929 'int[]' does not contain a definition for 'Contains'
錯誤 CS1929 'int[]' 不包含 'Contains' 的定義,並且最好的擴展方法重載 'Queryable.Contains(IQueryable, int?)' 需要一個類型為 'IQueryable 的接收器
一旦我嘗試運行代碼,就會出現此錯誤,我不知道如何修復它。 這是代碼
public void SendModelPallet(string IDs, StorageContext db)
{
int[] ids = ViewModelsUtils.processIDs(IDs);
PalletBoxes = db.ExternStoragePlaces.Where(c => ids.Contains(c.PalletPlaceID)).ToList();
this.db = db;
}
提前致謝
這里只是一個猜測,但我記得在某些 Linq to SQL 查詢中遇到 nulll 合並問題。 我建議您嘗試將您的 ids 數組聲明為:
int?[] ids = ViewModelsUtils.processIDs(IDs);
(使用int?[]
而不是int[]
這樣這將匹配您的字段類型)
對此不確定,首先是因為它似乎與編譯錯誤消息不匹配,其次是因為我暫時沒有辦法對此進行測試。
在使用 Delegates[] 並用於獲取CS1929: 'Delegate?[]' does not contain a definition for 'Contains'
同樣的問題CS1929: 'Delegate?[]' does not contain a definition for 'Contains'
剛剛包含System.Linq
命名空間,現在工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.