简体   繁体   English

在nHibernate中ICriteria和ICriterion之间有什么区别/优势?

[英]What's the difference/advantages between ICriteria and ICriterion in nHibernate?

Bit of a newbie question as Im getting started with nHibernate. 我开始使用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? NHibernate.Criterion.ICriterionNHibernate.ICriteria类有什么区别,我应该将它用于简单的“ where field=value ”类型过滤?

An ICriteria is used to represent a query. ICriteria用于表示查询。 You can add ICriterions to this ICriteria to express filters. 您可以将ICriterions添加到此ICriteria以表示过滤器。

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 ICriterion:查询标准的面向对象表示,可用作ICriteria查询中的约束

ICriteria: a simplified API for retrieving entities by composing NHibernate.Criterion.Expression objects. ICriteria:一个简化的API,用于通过组合NHibernate.Criterion.Expression对象来检索实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM