Bit of a newbie question as Im getting started with nHibernate.
What's the difference between NHibernate.Criterion.ICriterion
and NHibernate.ICriteria
classes and which should I use for simple "where field=value
" type filtering?
Bit of a newbie question as Im getting started with nHibernate.
What's the difference between NHibernate.Criterion.ICriterion
and NHibernate.ICriteria
classes and which should I use for simple "where field=value
" type filtering?
An ICriteria is used to represent a query. You can add ICriterions to this ICriteria to express filters.
For instance:
ICriteria crit = session.CreateCriteria (typeof(Person));
crit.Add (NHibernate.Criterion.Expression.Eq("Name", "somename"));
Or, as the documentation states:
ICriterion: An object oriented representation of a query criterion that may be used as a constraint in an ICriteria query
ICriteria: a simplified API for retrieving entities by composing NHibernate.Criterion.Expression objects.