alias - Query DTO with DTO collection NHibernate -


i have objecta (with corresponding objectadto) collection of objectb (with corresponding objectbdto). how can query objecta join on objectb , map them both dtos? don`t want query db.

    class objecta {         public string name { get; set; }         public byte[] garbage { get; set; }         public ienumerable<objectb> collection { get; set; }     }      class objectb {         public string name { get; set; }         public byte[] garbage { get; set; }         public objecta parent { get; set; }     } 

// maps =>

    class objectadto {         public string name { get; set; }         public ienumerable<objectbdto> collection { get; set; }     }      class objectbdto {         public string name { get; set; }         public objectadto parent { get; set; }     } 

could this:

objectb objectbalias = null; var query = _session.queryover<objecta>() .joinalias(x=>x.collection, ()=> objectbalias, jointype.leftouterjoin) .list();  var list = query.select(x=>new objectadto {    name=x.name,    children=x.collection.select(c=>new objectbdto {name=c.name, parent=x).tolist() }) .tolist(); 

didn't check syntax in vs, idea


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -