我有一个问题,你在那里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)