I have the following in subquery which is failing:
var subquery = QueryOver.Of<Product>()
.Where(x => x.ProductCategories.Any(y => y.Categgory == parameter.Category));
I get an error for the Any statement:
Unrecognised method call: System.Linq.Enumerable:Boolean Any
How would I update the above restriction for QueryOver?
QueryOver is a strongly-typed version of Criteria, and is more NHibernate specific. Pretty much anything you can do in ICriteria can be done with QueryOver.
The DetachedCriteria class lets you create a query outside the scope of a session, and then later execute it using some arbitrary ISession. A DetachedCriteria may also be used to express a sub-query.
ProductCategory productCategory = null;
var subquery = QueryOver.Of<Product>()
.JoinAlias(product => product.ProductCategories, () => productCategory)
.Where(() => productCategory.Category.Id == parameter.Category.Id);
What's type of Category? If this is an entity:
productCategory.Category.Id == parameter.Category.Id
If this is base property:
productCategory.Category == parameter.Category
Is it many-to-many relation? (Product and Category)
Category category = null;
var subquery = QueryOver.Of<Product>()
.JoinAlias(product => product.Category, () => category)
.Where(() => category.Id == parameter.Category.Id);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With