select p from Parent p join p.Children c where p.id in (:parentList) and c.SomeProp = :someValue
On Wed, May 5, 2010 at 12:43 PM, Sandra <[email protected]> wrote: > Hi all, > > I'm having a problem with NHIbernate and was hoping you could help. > Not sure if it's a bug in NHibernate or not. > > I have an object 'Parent' which has a list of Children: (many-to-many > relation) > > class Parent {Id, Name, IList<Child> children} > class Child {Id, Name} > > I need to select all parents where there is a condition for their > children but I do not want to get duplicate rows (don't want the > children details to appear in select list) > > Here is the code: > > session.CreateCriteria(typeof(Parent)) .SetFetchMode("children", > FetchMode.Select); > .CreateCriteria("children").Add(Subqueries.PropertyIn("Id", > {1,2,3,4})) .List(); > > Although i have tried setting the fetch mode to lazy load but the > query still adds all proprties of child class to select list which > results in duplicate rows. > > Is there any way I can select all parents without having the child > details in the select list? > > How to join a table (Parent) with a secondary table (Child) without > selecting the second table's columns? > > I appreciate your help, > > Thanks > > Sandra > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- 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.
