nhibernate - QueryOver to return full tree hierarchy -


given following entity:

public class comment {     public int id { get; set; }     public ilist<comment> childcomments { get; set; } } 

i want load full tree, ie comment children plus children , on using queryover given id. unfortunately dont know begin.

setting mappings eager load collection isnt option me either.

is there way or need use hql in case?

thanks.

well, think need future queries , distinctrootentityresulttransformer

i can show how criteria , recommend same. in our project linq 1 had ugly , magic strings. group object many members , many subgroups. after executing query root (the root element parent null) hold loaded objects in it. case should add restriction commendid also, each fetch have done in separate future query. luck

public static groupdto getgrouphierarchy(this isession session)     {         session             .createcriteria<groupdto>()             .add(expression.eq("isactive", true))             .setfetchmode("subgroups", nhibernate.fetchmode.eager)                 .setresulttransformer(new distinctrootentityresulttransformer())                 .future<groupdto>();          var groups = session                .createcriteria<groupdto>()                .add(expression.eq("isactive", true))                    .setfetchmode("members", fetchmode.eager)                    .setresulttransformer(new distinctrootentityresulttransformer())                    .future<groupdto>();          return groups.single(g => g.parent == null);     } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -