0

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();
4

1 に答える 1

0

コメントがツリー内でどれだけ深いかを示す何らかのインジケータがなければ、ベンダー固有の再帰に頼らずに 1 つのステートメントで SQL のセットを記述する方法はありません。最も簡単な方法は、ツリー全体を取得し、コードでフィルター処理することです。

于 2012-06-08T07:19:16.260 に答える