【发布时间】:2013-04-30 18:24:21
【问题描述】:
给定一个父对象列表,每个父对象都有一个子对象列表,我想找到与特定 ID 匹配的子对象。
public class Parent
{
public int ID { get; set; }
public List<Child> Children { get; set; }
}
public class Child
{
public int ID { get; set; }
}
现在我希望 Child 对象具有特定的 ID:
List<Parent> parents = GetParents();
Child childWithId17 = ???
如何使用 Linq 做到这一点?
【问题讨论】: