gpt4 book ai didi

c# - int' 不包含 'contains' 的定义,并且找不到接受类型为 'contains' 的第一个参数的扩展方法 'int'

转载 作者:行者123 更新时间:2023-11-30 23:14:38 24 4
gpt4 key购买 nike

我在使用下面的 LINQ 查询时遇到下面提到的错误,什么是 not inSQL to LINQ?我试过 where !cl.change_list_id.contains(from clcl在 bitDB.component_labels_change_lists 中选择 clcl.change_list_id) 哪个不起作用?

var lookaheadRunChangeListIds = (from lrcl in bitDB.lookahead_run_change_list
join cl in bitDB.change_lists on lrcl.change_list_id equals cl.change_list_id
where lrcl.lookahead_run_id == lookaheadRunId
//and cl.change_list_id not in (select clcl.change_list_id from component_labels_change_lists as clcl)
where !cl.change_list_id.contains(from clcl in bitDB.component_labels_change_lists select clcl.change_list_id)
select cl.change_list.ToString()).ToList();

错误

Error 4 'int' does not contain a definition for 'contains' and no extension method 'contains' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

最佳答案

序列包含 id 而不是相反,这就是错误的说明。你应该交换这些:

!(from clcl in bitDB.component_labels_change_lists 
select clcl.change_list_id).Contains(cl.change_list_id)

你也可以试试:

!bitDB.component_labels_change_lists.Any(clcl => clcl.change_list_id == cl.change_list_id)

但是检查生成的查询并选择更快的查询(这可能对这个有帮助:https://stackoverflow.com/a/1412902/3185569)

关于c# - int' 不包含 'contains' 的定义,并且找不到接受类型为 'contains' 的第一个参数的扩展方法 'int',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42969157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com