[英]Error CS1929 'int[]' does not contain a definition for 'Contains'
Error CS1929 'int[]' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains(IQueryable, int?)' requires a receiver of type 'IQueryable
错误 CS1929 'int[]' 不包含 'Contains' 的定义,并且最好的扩展方法重载 'Queryable.Contains(IQueryable, int?)' 需要一个类型为 'IQueryable 的接收器
once i try to run the code this error comes out , i dont know how to fix it.一旦我尝试运行代码,就会出现此错误,我不知道如何修复它。 this is the code
这是代码
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;
}
Thanks in advance提前致谢
Just a guess here, but I remember having had problems with nulll coalescing in some Linq to SQL queries.这里只是一个猜测,但我记得在某些 Linq to SQL 查询中遇到 nulll 合并问题。 I recommend you to try to declare your ids array as this :
我建议您尝试将您的 ids 数组声明为:
int?[] ids = ViewModelsUtils.processIDs(IDs);
(use int?[]
instead of int[]
so this will match the type of your field) (使用
int?[]
而不是int[]
这样这将匹配您的字段类型)
Not sure about this, first because it doesn't seem to match the compilation error message, and secondly because I don't have a way to test this for the moment.对此不确定,首先是因为它似乎与编译错误消息不匹配,其次是因为我暂时没有办法对此进行测试。
Had the same issue while using Delegates[] and used to get the CS1929: 'Delegate?[]' does not contain a definition for 'Contains'
在使用 Delegates[] 并用于获取
CS1929: 'Delegate?[]' does not contain a definition for 'Contains'
同样的问题CS1929: 'Delegate?[]' does not contain a definition for 'Contains'
Just included the System.Linq
namespace and works fine now.刚刚包含
System.Linq
命名空间,现在工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.