, HQL, API- NHibernate, :
ICriteria criteria = session.CreateCriteria (typeof(Technology));
criteria.SetFetchMode ("TechnologyDescriptions", FetchMode.Lazy);
var list = criteria.List<Technology>();
, , , . , ( : TechnologyDescriptions).
NHibernate "". , "".
Entirly ( ). , ;
NHibernate , , ?
- , :
, , , - ?
"".
, , TechnologyView, :
public class TechnologyView
{
public int Id
{
get;
private set;
}
public string Name
{
get;
private set;
}
public string Abbreviation
{
get;
private set;
}
private TechnologyView()
{
}
public TechnologyView( int id, string name, string abbreviation )
{
this.Id = id;
this.Name = name;
this.Abbreviation = abbreviation;
}
}
, NHibernate .
, hbm.xml, . ( , , Fluent).
<import class="MyNamespace.TechnologyView" />
( HQL ), TechnologyView. NHibernate , SQL-.
HQL:
IQuery q = s.CreateQuery ("select new TechnologyView (t.Id, t.Name, t.Abbreviation) from Technology t");
:
ICriteria criteria = s.CreateCriteria (typeof(Technology));
criteria.SetResultTransformer (Transformers.AliasToBean (typeof(TechnologyView));
var result = criteria.List<TechnologyView>();