小编Irr*_*rks的帖子

linq嵌套列表包含

我有一个问题,你在那里linq专家!在组件实例的嵌套列表中,我需要知道其中是否存在特定类型的组件.可以用linq表达吗?考虑到可能有application.Components [0] .Components [0] .Components [0] ...我的问题是面向linq中的递归查询!

我告诉你实体让你对模型有所了解.

public class Application
{
    public List<Component> Components { get; set; }
}

public class Component
{
    public ComponentType Type { get; set; }
    public List<Component> Components { get; set; }
}

public enum ComponentType
{
    WindowsService,
    WebApplication,
    WebService,
    ComponentGroup
}
Run Code Online (Sandbox Code Playgroud)

c# linq tree recursion nested-class

6
推荐指数
1
解决办法
2965
查看次数

标签 统计

c# ×1

linq ×1

nested-class ×1

recursion ×1

tree ×1