SL 将分层数据转换为平面数据以填充 DataGrid
我有一个对象列表,每个对象都有一个 Children 属性,它是一个对象列表,而该属性又具有一个 Children 属性,它是一个对象列表......同样的东西有 4 层深。我试图提取整个层次结构中的每个对象实例。在层次结构的每个级别上,它仍然是相同类型的对象。
我尝试过使用 LINQ,但到目前为止还没有成功。
有人有另一个角度来解决这个问题吗?
I have a list of Object's, each Object has a Children property which is a list of Object's, which in turn has a Children property which is a list of Object's ... the same thing 4 layers deep. I'm trying to pull out every instance of Object inside the entire hierarchy. At each level down the hierarchy it's still the same type of Object.
My attempts have involved using LINQ but so far no dice.
Does anyone have another angle to approach this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确地遵循你的逻辑,我认为你正在寻找的东西就像这个人想要的一样......
LINQ:如何将嵌套分层对象转换为展平对象
听起来您正在尝试展平可以通过递归函数来完成的对象。
If I am following your line of logic correctly I think what you are looking for is something like what this guy wanted ...
LINQ: How to convert the nested hierarchical object to flatten object
Sounds like you are trying to flatten the object which you can do through a recursive function.