Hello,
According to the answer http://stackoverflow.com/questions/5796036/nhibernate-projecting-child-entit ies-into-parent-properties-with-linq-or-queryove?tab=active#tab-top using Criteria I came up with a translation to QueryOver like this : Operation operations = null; var q = GetSession().QueryOver<User>().Where(u => u.AccessKeyId == accessKeyId) .Left.JoinQueryOver(x => x.Operations, () => operations) .Select(Projections.ProjectionList() .Add(Projections.Sum<User>(x => callWebServicesView. NbSuccessfulAccesses), "TotalSuccessfulAccesses")) .Add(Projections.Sum<User>(x => callWebServicesView. NbFailedAccesses), "TotalSuccessfulAccesses")) .TransformUsing(Transformers.AliasToBean<UserViewModel>()).List< UserViewModel >(); which works great. However it seems that I have to use string to the name of alias "TotalSuccessfulAccesses" and "TotalSuccessfulAccesses" because if I use something like that UserViewModel userView = null; .Add(Projections.Sum<User>(x => callWebServicesView. NbSuccessfulAccesses), () => userView.TotalSuccessfulAccesses) NHibernate yields an error : Could not find a setter for property 'userView.TotalSuccessfulAccesses' in class 'Domain.Query.UserViewModel' which is not true because there is a setter for TotalSuccessfulAccesses' property. Any thoughts ? Thank you in advance. Thomas De : Thomas JASKULA [mailto:[email protected]] Envoyé : mardi 26 avril 2011 23:30 À : [email protected] Objet : NHibernate projecting child entities into parent properties with Linq or QueryOver Hello, I’m trying to make a projection with QueryOver. I posted my question on SO because I’m stuck with it. Here’s the link http://stackoverflow.com/questions/5796036/nhibernate-projecting-child-entit ies-into-parent-properties-with-linq-or-queryove. Thanks in advance for your help. Thomas -- 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.
