我有一个包含另一个ObservableCollection的ObservableCollection。
ObservableCollection<MyModel> models = new ObservableCollection<MyModel>();
我的模型看起来像这样:
public class MyModel
{
public ObservableCollection<MyModel2> list2 { get; set; }
public string Property1 { get; set; }
}
public class MyModel2
{
public string Property2 { get; set; }
public string Property3 { get; set; }
}
现在我想在models中查找所有"MyModel2"项目,其中 "Property2" == "test1" 且 "Property3" == "test2"。我知道如何在一个列表中搜索以找到正确的项目,但我想在models集合中搜索所有"list2"。
var result = from mod
in list2
where mod.Property2 == "test1" && mod.Property3 == "test2"
select mod;
任何帮助都将不胜感激。
.Select
=>.SelectMany
? - Rawling