I have two different collections:
List<int>
IEnumerable<IDataRecord>
The first contains a list of primary keys. The second contains data records. What I would like to do is determine which primary keys in the first collection do not exist in the second based on a given column name and return them as a new collection.
For example, if I have this:
private List<int> _currentKeys = new List<int>();
public void Update(DbDataReader reader, string keyColumn) {
var records = reader.AsEnumerable(); // my own extension method
var difference = // LINQ stuff here
}
Say _currentKeys
contains [1, 2, 3, 4, 5] and reader
contains records with the values [1, 4, 5] in a column called ID. If I call Update, I need to get a collection containing [2, 3].
As always, I have a feeling that this is super simple, but the fact that the two collections are different types completely threw me off. Combined with the fact that I haven't used LINQ much yet.