1

使用 AddOrder 方法检索添加到 ICriteria 对象的订单列表的最佳方法是什么?我相信这必须使用反射来完成,但是要反思什么呢?

这样做的目的是我想将排序顺序传递回 UI,以便可以向用户提供排序顺序的指示。

4

1 回答 1

2
var impl = session.CreateCriteria<User>().AddOrder(Order.Asc("Id")) as CriteriaImpl;

foreach (CriteriaImpl.OrderEntry entry in impl.IterateOrderings())
{
Order order = entry.Order;
    // now you have the order and you can either parse it : "propertyName asc" 
                                                         or "propertyName desc"
    // or you can check it out in debug, it has a few protected fields that you could reflect. 
    // not sure if there's another way.
}
于 2009-08-05T16:02:23.210 回答