Search code examples
c#nhibernatefluent-nhibernatecriterianhibernate-criteria

How to get count of Junction criteries in NHibernate


I Compose NHibernate Query using Criterion

Junction criterion = Restrictions.Conjunction();
criterion.Add(something1);
criterion.Add(something2);
....
criterion.Add(somethingN);

and how can I get count of criteries in criterion like criterion.GetCountOfCriteries()

In Source code of Junction I see list of criteries

private readonly IList<ICriterion> criteria = new List<ICriterion>();

but it has modifier as private.

Some ideas?


Solution

  • It is not possible. And it is not intended. Why? Because we work with ICriteria API and not with its implementation (what we can see in code or debugger).

    So, if there will be different implementation of ICriteria... none can grant there will be some readonly ILIst<ICriterion> at all...

    As a solution I would suggest - do that outside of the ICriteria API (if really needed). And, maybe try to re-check if such information is needed.