开发者

NHibernate Criteria.AddOrder(Order.Asc("Column.Property"))

I have an OrderEntity that has a property OrderStatistics that has a property CreateDate. It looks like Order.OrderStatistics.CreateDate.

I will like to fetch all orders and sort them by CreateDate.

  1. fetchQuery.UnderlyingCriteria.AddOrder(Order.Asc(开发者_运维百科"OrderStatistics.CreateDate")) does not wokr

  2. fetchQuery.UnderlyingCriteria.AddOrder(Order.Asc("CreatorName")) works

    How can I make 1 work ?

Thank you,


fetchQuery
    .UnderlyingCriteria
    .CreateAlias("OrderStatistics", "stats")
    .AddOrder(Order.Asc("stats.CreateDate"))

Or

OrderStatistic stats = null;
fetchQuery
    .CreateAlias(order => order.OrderStatistics, () => stats)
    .OrderBy(() => stats.CreateDate);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜