Hey all,
Hopefully I can explain this to where it make sense, but I'm trying to get a list of objects out of a master list using a speicific and complex (complex to me, at least) set of criteria.
I have a Class called TableInfo that exposes a List of ForeignKeyInfo. ForeignKeyInfo has a string property (among others) called, Table. I need to do some sequential processing using my TableInfo objects but only work with the TableInfo objects I haven't yet processed. To keep track of which TableInfo objects have already been processed I have a List which stores the name of the table after the processing has been complete.
I want to loop until all of the items in my TableInfo collection appear in my processed list. For each iteration of the loop, I should be processing all of the TableInfo items where all of the ForeignKeyInfo.Table strings appear in my processed List.
Here's how I've written it in "standard" looping code:
while(processed.Count != _tables.Count)
{
List<TableInfo> thisIteration = new List<TableInfo>();
foreach (TableInfo tab in _tables)
{
bool allFound = true;
foreach (ForeignKeyInfo fk in tab.ForeignKeys)
{
allFound = allFound && processed.Contains(fk.Table);
}
if (allFound && !processed.Contains(tab.Name))
{
thisIteration.Add(tab);
}
}
//now do processing using thisIteration list
//variable, "thisIteration", is what I'd like to replace with the result from LINQ
}