我正在尝试获取dataA中位于dataB中的项目子集,并且具有不同的属性c值。属性 a 和 b 可以用作索引,因此我尝试仅过滤掉有用的对,然后检查它们是否具有不同的 c 值。
这是我想出的 linq 表达式,它确实有效,但似乎必须有更好/更快的方法来找到这个子集。
var itemsInBoth = from item in dataA
from item2 in dataB
where item.a == item2.a && item.b == item2.b
select new
{
first= item,
second = item2
};
var haveDifferentC = from item in itemsInBoth
where item.first.c != item.second.c
select item.first;