2012-10-30 121 views
0

任何人都可以幫助我如何執行下面的nhibernate條件,以便Process類按SourceSystem.Name排序。Nhibernate標準按子集合屬性排序

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>(); 

感謝

+0

我嘗試使用.AddOrder(Order.Asc( 「Parameters.SourceSystem.Name」)),但毫無效果。 – elamaran

回答

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