我有点困惑这是如何工作的。
所以每个
我尝试了这个方法,但它没有起作用:
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
列表。
我想要做的是找到一个包含任何ID
为0
的Stuff
的TestClass
。List<TestClass> TestList = RetrieveAllTestLists();
//Pseudocode:
//
// Find all TestClass in TestList that contain a Stuff with ID == 0;
我尝试了这个方法,但它没有起作用:
List<TestClass> TestList = RetrieveAllTestLists().Where(x=> x.StuffList.Where(y=> y.ID == 0)).ToList();
有人可以解释一下我做错了什么吗?