我比较两个列表,查看是否包含从其他反之亦然值:来比较不同的两个列表比较快的方式对象
List<customer> NotOnLocal =
AllServer.Where(p => !AllLocal.Any(p2 => p2.Reference == p.customerNumber))
.ToList();
List<ConnectCustomer> NotOnServer =
AllLocal.Where(p => !AllServer.Any(p2 => p2.customerNumber == p.Reference))
.ToList();
这似乎很好地工作,但有超过10万个对象在每个比较中都会慢一点。有谁知道是否有更有效的方法来进行比较并返回相应的列表?
没有,可以很好地加快速度(至少为10倍),谢谢:) –