我对这是如何工作有点困惑。查找列表项内的列表项目
class TestClass
{
public int ID {get;set;}
public List<Stuff> StuffList {get; set;}
}
class Stuff
{
public int ID {get;set;}
public string Description {get;set;}
}
因此,每个TestClass
有在他们Stuff
列表。 我想要做的就是找到一个TestClass
包含与ID
的0
List<TestClass> TestList = RetrieveAllTestLists();
//Pseudocode:
//
// Find all TestClass in TestList that contain a Stuff with ID == 0;
的我已经试过这任何Stuff
但它没有工作:
List<TestClass> TestList = RetrieveAllTestLists().Where(x=> x.StuffList.Where(y=> y.ID == 0)).ToList();
谁能给我解释一下我做错了什么?