Nhibernate标准按子集合属性排序

时间:2012-10-30 14:23:10

标签: c# nhibernate

任何人都可以帮我如何执行下面的nhibernate标准,以便Process类按SourceSystem.Name排序。

public abstract class Process : DomainObject<int>
{
    public virtual IList<Paramater> Parameters  { get; set; }   
}

public class Paramater : DomainObject<int>
{
    public virtual SourceSystem SourceSystem     { get; set; }  
}

public class SourceSystem : DomainObject<int>
{
    public virtual string Name { get; set; }
}

process  = _session
.CreateCriteria<Process>()
.Add(Restrictions.Eq("Id", loadingProcessId))
.UniqueResult<Process>();

由于

1 个答案:

答案 0 :(得分:0)

process  = _session.CreateCriteria<Process>()
    .Add(Restrictions.Eq("Id", loadingProcessId))
    .CreateCrtieria("Parameters")
    .CreateCrtieria("SourceSystem", "SourceSystem")
    .AddOrder(Order.Asc("SourceSystem.Name"))
    .UniqueResult<Process>();