Is there any way to write LINQ (or with procedural style) query, that can select all children with one SQL query?

I have entity:


public class Comment
{
   public int Id {get;set;}
   public int ParentId {get;set;}
   public int Text {get;set;}
}

I have a ID, so I want to select Comment with ID and all its children with subchildren.

Example:


1
-2
--3
-4
-5
--6

2 3

If ID == 1 then I want list of 1,2,3,4,5,6.

asked Nov 21 '12 at 13:22

Ness's gravatar image

Ness
155232328

edited Nov 22 '12 at 03:44


One Answer:

Hello Ness,

some SQL dialects have extensions for recursive queries, but this is not supported by DataObjects.Net

Generally if you are going to have good performance it's better to implement some tree storage pattern such as materialized path.

answered Nov 22 '12 at 03:37

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Ok, thanks.

(Nov 22 '12 at 03:48) Ness Ness's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×31
×1

Asked: Nov 21 '12 at 13:22

Seen: 7,424 times

Last updated: Nov 22 '12 at 04:00

powered by OSQA