vb.net – Linq – 从不同列表类型中排除项目
发布时间:2020-12-17 07:26:35 所属栏目:百科 来源:网络整理
导读:有没有办法在列表中选择未包含在另一个中的项目?例如: list1 = From t In list1 Where Not list2.Contains(t.column1) 这给了我错误: Value of type 'Integer' cannot be converted to 'anonymous type' 这是有道理的,因为list2.Contains期望与list2相同
有没有办法在列表中选择未包含在另一个中的项目?例如:
list1 = From t In list1 Where Not list2.Contains(t.column1) 这给了我错误: Value of type 'Integer' cannot be converted to '<anonymous type>' 这是有道理的,因为list2.Contains期望与list2相同的类型.但是,列表类型不同.我只想根据列比较进行选择. 解决方法
你尝试过这样的事吗?
list1 = From t In list1 Where Not list2.Any(l => t.column1 = l.column1 AndAlso t.column2 = l.column2) 我不确定它会有多高效,但我认为它应该适合你. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |