如何通过Bag的代码降序在Nhibernate映射中进行排序?

时间:2019-04-12 09:54:46

标签: c# linq nhibernate-mapping mapping-by-code

我有一个按代码对多的包映射,我想按desc顺序按两列(当前列和目标列)进行排序,但是IBagPropertiesMapper没有OrderByDescending()和ThenByDescending()方法。仅void OrderBy<TProperty>(Expression<Func<TElement, TProperty>> propertyvoid OrderBy(string sqlOrderByClause)。我也不知道如何使用字符串sqlOrderByClause。

班级

 public class Application{
        public virtual int Id { get; set; }
        public virtual IList<Record> Records { get; set; }
 }

 public class Record{
        public virtual Application Application { get; set; }
        public virtual bool Current { get; set; }
        public virtual DateTime? From { get; set; }
        public virtual DateTime? To { get; set; }
}

 public ApplicationMap(){
        Bag(x => x.Records,
                cm => {
                    cm.Inverse(true);
                    cm.Key(km => km.Column("ApplicationId"));
                    cm.OrderBy();
 }

0 个答案:

没有答案