foreach (SchemaInfo db in SourceSchemaInfos)
{
foreach (SchemaInfo table in db.SchemaInfos)
{
foreach (SchemaInfo tablelist in table.SchemaInfos)
{
for (int i = 0; i < SelectedTables.Count; i++)
{
if (tablelist.Key == SelectedTables[i].Key)
{
foreach (SchemaInfo _tableschema in tablelist.SchemaInfos)
{
_tableschema.IsSelected = true;
}
}
}
}
}
}
我试图将上述 foreach 循环转换为 linq 查询,如下所示。
SourceSchemaInfos.ForEach(Database =>Database.SchemaInfos.ForEach(items => items.SchemaInfos.ForEach(tables => tables.SchemaInfos.Where(tables.Key == SelectedTables.ForEach(l => l.Key)).ForEach(m => m.IsSelected = true))));
但它让我出现以下错误@l.Key
CS0201 Only assignment, call, increment, decrement, and new object expressions can be used as a statement
`