That kind of query is easier with HQL: select elements(p.Categories) from Product p where p.Name = 'Television'
Anyway, I don't know your use case, but you could just load the Product... Diego On Mon, Dec 14, 2009 at 10:01, Andyk <[email protected]> wrote: > I have a domain object called Product, that has a many to many > collection of type Category. > I want to retrieve just the categories that belong to a specific > Product. > > var result = Session.CreateCriteria<Product>() > .Add(Restrictions.Eq("Name", "Television")) > .CreateCriteria("Categories") > .List<Category>(); > > This returns an "unable to perform sql" error. > > > Am I supposed to be doing a projection instead? I assumed an extra > "CreateCriteria" would be enough. > > > > > Andy > > -- > > 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.
