开发者

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

开发者 https://www.devze.com 2023-03-26 18:42 出处:网络
I have an OrderEntity that has a property OrderStatistics that has a property CreateDate. It looks like Order.OrderStatistics.CreateDate.

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

精彩评论

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