Hello!
try
var result = Session.CreateCriteria<Product>()
                .CreateCriteria("Categories")
                .Add(Restrictions.Eq("Name", "Television"))
                .List<Product>();

i think you have to use hql to be able to fetch something else than
the root type if you not are projecting anything.

select categories
from Product p
join p.Categories categories
where Name = 'Television'

On 14 Dec, 14: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].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.


Reply via email to