so basically I have two large lists like following:
public class Items
{
public string ItemID { get; set; }
}
var oldList = new List<Items>(); // oldList
var newList = new List<Items>(); // new list
Both lists are very large, and a simple double foreach wouldn't be sufficient due to poor execution time if they are both large (more than 30 seconds).
In previous question that I've asked on stackoverflow I got a reply on how to compare these two same lists and find out which items have different QuantitySold parameter, and then store it in a third list called "DifferentQuantityItems" like following:
var differentQuantityItems =
(from newItem in newList
join oldItem in oldList on newItem.ItemID equals oldItem.ItemID
where newItem.QuantitySold != oldItem.QuantitySold
select newItem).ToList();
Now what I would like to get from these two lists is following:
- A list of items that are present in newList, but not in oldList
- A list of items that are present in oldList, but not in newList
How can I achieve this ? Can someone help me out?
P.S. The way I would "know" that either item is missing from one of the lists is by property "ItemID"...