How to find all parents?

17 views
Skip to first unread message

mynkow

unread,
Jun 7, 2012, 8:28:48 AM6/7/12
to nhu...@googlegroups.com

I have a Comment object. Each comment can have child comments. Each comment tree has the same CommentContainer so we can load the correct comment tree. I can construct the tree with the query below but I want to get only the parents of a specific comment. Any ideas?

class Comment
{
  prop
Comment Parent{get;set;}
  prop
CommentContainer Container{get;set;}
}

(from comment in Session.Query<CommentDto>()
 
from parent in Session.Query<CommentDto>()
 
where comment.CommentContainer.Id == CommentContainderID && comment.Parent == parent
 
select comment)
.Fetch(c => c.Parent)
.ToList();

Alexander I. Zaytsev

unread,
Jun 7, 2012, 12:12:44 PM6/7/12
to nhu...@googlegroups.com
Hi, please try following code:


(from comments in Session.Query<CommentDto>()
where comment.CommentContainer.Id = CommentContainerID
select comment.Parent).ToList()


2012/6/7 mynkow <myn...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/uXsZfgHSRvAJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

mynkow

unread,
Jun 7, 2012, 12:27:45 PM6/7/12
to nhu...@googlegroups.com
Hi,

this will not work because it will select all branches of the tree. I need only 1 branch.


2012/6/7 mynkow <myn...@gmail.com>
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages