我有两个看起来像这样的对象模型:
public class MyObject
{
public List<SomeOtherObject> TheListOfSomeOtherObjects { get; set; }
}
public class SomeOtherObject
{
long SomeOtherObjectID { get; set; }
}
我有一个MyObjects
被调用列表ListOfMyObjects
,我想从中提取SomeOtherObjectID
列表中的所有内容TheListOfSomeOtherObjects
我想写这样的东西:
var ListOfAllSomeOtherObjectID = (from l in ListOfMyObjects
select l.SomeOtherObject.SomeOtherObjectID ).ToList();
由于语法,它不起作用。如何获取嵌套列表的列表?
感谢您的建议。