Question

What is the best way to retrieve the list of Orders added to an ICriteria object using the AddOrder method? I believe this will have to be accomplished using Reflection, but what to reflect on?

The purpose of doing this is that I would like to pass the sort order back to the UI so an indication of the sort order can be provided to the user.

Was it helpful?

Solution

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.
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top