Reputation: 8875
hey guys, I'm using NHibernate version 2.1.2.4000.
class bowl
{
int id { get; set; }
List<fruit> fruits { get; set; }
}
var bowls = repository.where(b => b.fruits.count > 1);
How do I do the above query using the NHibernate criteria API?
Ideally I'd like to be able to do something like this (no subqueries, no detached criterias):
var bowls = repository.where(Restrictions.Gt("fruits.count", 1));
Is the above possible somehow?
cheers!
Upvotes: 0
Views: 150
Reputation: 64628
It's only possible with detached criteria.
On the other hand, filtering by "count" is very easy using HQL:
from bowl where fruits.size > 1
Criteria API is not as powerful as HQL. Unfortunately, all this linq-style API's are based on criteria.
Upvotes: 1