これがどのように機能するかについて少し混乱しています。
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
を含む任意のStuff
を見つけることID
です0
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();
誰かが私が間違ったことを説明できますか?