Search code examples
nhibernatequeryovernhibernate-criteriadetachedcriteria

How to translate a QueryOver to DetachedCriteria?


I do not wish to know why it's better to use QueryOver and that it's newer.

How can I translate the following QueyOver to a DetachedCriteria:

QueryOver<Category>().Where(x => x.Properties.Any(y => y.Locales.Any(l => l.Value.Name == "propName")));

I don't know if the "Any" extension method is recognized by nhibernate but you can understand what I'm trying to accomplish.


Solution

  • var subquery = DetachedCriteria.For<Category>()
        .CreateCriteria("Properties")
            .CreateCriteria("Locales")
                .Add(Expression.Eq("Name", "propName"));