如何确定 NHibernate ICriteria 对象的排序顺序?

发布于 2024-07-30 00:31:07 字数 128 浏览 4 评论 0原文

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鱼窥荷 2024-08-06 00:31:08
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.
}
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.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文