Yes i get the meaning. Nhibernate knows about relations.
If i ask nhibernate to populate the user class it will do it in two steps. First the user then the ProjectGroups. I am only transforming this entity to a DTO(they are equal). Since i don't know enough of this projections i asked first before i went to custom code. Now this must be a two step from me. First get the user then the ProjectGroups of the user and combine them. I am just not a great fan of such customization. Thank you anyway for the responses... On May 17, 1:27 am, Fabio Maulo <[email protected]> wrote: > I think this is a new "moda" because more than one is asking for this...Try > to think about this > select hf.Id, hf.FamilyName, hf.Pets from HumanFamily hf > > The RDBMS SQL allow only 2 dimensional result so ... > SELECT hf.Id, hf.FamilyName, pet.* FROM HumanFamily hf JOIN Animal a on > a.OwnerId = hf.Id > > Now somebody should say to NH how create a on-the-fly-KeyObject of hf.Id, > hf.FamilyName, with its Equals and GetHashCode implemented, and group all > result by this new anonymous object and return a IDictionary<anonymous, > IList<Animal>>. > > Instead do it so complicated you can simple do something like > from HumanFamily hf join fetch hf.Pets > Then, using LINQ, transform the result in what you want in a single code > line (or so). > > 2009/5/16 mantzas <[email protected]> > > > > > > > HI, > > > given a Class lets say > > > public class User > > { > > public virtual int Id {get;set;} > > public virtual IList<ProjectGroup> ProjectGroups{get;set;} > > } > > > and a DTO > > > public class UserDTO > > { > > public int Id {get;set;} > > publicIList<ProjectGroupDTO> ProjectGroups{get;set;} > > } > > > i want to project the results from the User to UserDTO. > > > DetachedCriteria dc = DetachedCriteria.For(typeof (User)); > > dc.CreateAlias("ProjectGroups", "pg"); > > dc.SetProjection(Projections.ProjectionList() > > .Add(Projections.Property("Id"),"Id") > > .Add(Projections.Property > > ("User.UserGroups"), )); > > > dc.SetResultTransformer(Transformers.AliasToBean(typeof (UserDTO))); > > > something is missing or simply i dont get it!!! > > > Can someone please guide me??? > > > Thx > > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
