我正在使用FluentNhibernate,当我尝试按属性订购商品时,它以无法解释的顺序返回结果。我有一对一的相关表格
public class Docs
{
public virtual int Id{get;set;}
public virtual DocViewed DocViewed{get;set;}
}
public class DocViewed
{
public virtual int Id {get;set;}
public virtual Docs Doc {get;set;}
}
publuc class Docs
{
Id(x=>x.Id).GenerateBy.Identity();
HasOne(x=>x.DocViewed).Cascade.All();
}
publuc class DocViewedMap
{
Id(x=>x.Id).GenerateBy.Identity();
References(x=>x.Docs).Columns("Doc_id").Unique();
}
我的查询
var query = session.Query<Docs>().OrderByDescending(x=>x.DocViewed.Id);
我认为是因为&#39; DocViewed&#39; 没有&#39;文档&#39; 的所有记录,但此查询也是对我不起作用
var query = session.Query<Docs>().OrderByDescending(x=> x.DocViewed!=null).OrderByDescending(x=> x.DocViewed.Id);