Recursive LINQ query: select item and all children with subchildren

前端 未结 3 1878
梦谈多话
梦谈多话 2020-11-30 03:26

Is there any way to write a LINQ (or procedural style) query, that can select an item and all children with one query? I have entity:

public class Comment
{
         


        
3条回答
  •  [愿得一人]
    2020-11-30 03:58

    Your comment class can be seen as a graph and your problem is a Graph traversal problem.

    You can't really define recursive problems through linq, but the problem can very easily be resolved by a simple recursive method.

提交回复
热议问题