Then you need to add that as another property in the ProjectionList

John Davidson

On Wed, May 5, 2010 at 12:04 PM, Sandra <[email protected]> wrote:

> Thanks for your reply.
> I've already tried it. The problem with this method is that I will not
> have access to other properties on my main class.
> In my real application the main class has more properties which I need
> to be lazy loaded.
>
> If my class has list of cars for example then I wouldnt be able to
> load parent cars.
>
> Thanks
>
> On May 5, 4:57 pm, John Davidson <[email protected]> wrote:
> > You need to use projections to limit the fields returned
> >
> > session.CreateCriteria(typeof(Parent)) .SetFetchMode("children",
> > FetchMode.Select);
> > .CreateCriteria("children").Add(Subqueries.PropertyIn("Id",
> >
> {1,2,3,4})).SetProjections(Projections.List().Add(Projections.Property("Id")).Add(Projections.Property("Name")))
> > .List();
> >
> > John Davidson
> >
> >
> >
> > On Wed, May 5, 2010 at 11:43 AM, 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]>
> <nhusers%[email protected]<nhusers%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
> >
> > --
> > 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 athttp://
> groups.google.com/group/nhusers?hl=en.
>
> --
> 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.
>
>

-- 
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.

Reply via email to