Telerik MVC 网格分组与 nHibernate

发布于 2024-12-27 18:02:42 字数 606 浏览 4 评论 0原文

我有一个带有 nHibernate 项目的 MVC3,我想使用 Telerik MVC Extensions Grid。通过将过滤、分页和排序参数传递给 nHibernate,网格必须表现良好。这可以使用 IQueryable 来完成此处描述。然而, 根据 Telerik,nHibernate linq提供程序不理解 mvc 网格生成的 group by 查询。

他们的示例已经有一年多了,所以我刚刚将他们提供的示例项目更新为 MVC3、nHibernate 3.2 和 Telerik Extensions 2011.3.1115,当我将列拖到“Group By”中时,示例项目会抛出错误空间。我猜问题仍然存在。

有没有办法让它工作,或者在 nHibernate 支持 Telerik Grid 生成的 group by 语法之前什么也做不了?

I have an MVC3 with nHibernate project, and I would like to make use of the Telerik MVC Extensions Grid. The grid must perform well by passing the filtering, paging, and sorting parameters to nHibernate. This can be done described here with IQueryable. However,
according to Telerik, nHibernate linq provider doesn't understand the group by query the mvc grid generates.

Their example is more than a year old, so I've just updated the sample project they provide to MVC3, nHibernate 3.2, and Telerik Extensions 2011.3.1115 and the sample project throws an error when I drag a column into the "Group By" space. I'm guessing the problem is still there.

Is there a way to get this to work, or nothing can be done until nHibernate supports the group by syntax that the Telerik Grid is generating?

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

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

发布评论

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

评论(2

跨年 2025-01-03 18:02:42

无法像使用 IQueryable 那样自动执行此操作,但是,您可以使用自定义绑定手动执行此操作。请在此处查看演示。基本上,您的控制器操作将获取一个命令类作为参数,该参数将列出您的过滤器、组、排序和分页信息。然后,您将需要使用此信息来构建您的查询。

There is no way to do it automatically like with an IQueryable, however, you can do it manually by using custom binding. Take a look at the demo here. Basically your controller action will get a command class as an argument that will list your Filter, Group, Sort, and Paging info. You will then need to use this information to build up your query.

微暖i 2025-01-03 18:02:42

解决方案

我进行了分组以使用自定义绑定。有一个名为 TelerikMvcGridCustomBindingHelper 的帮助程序库,可以让这变得轻而易举。我非常喜欢自定义方法,因为它可以轻松拦截网格和 ORM 之间交换的数据。我建议你尝试一下。

Workaround solution

I got grouping to work with custom binding. There is a helper library called TelerikMvcGridCustomBindingHelper that can make this a piece of cake. I like the custom approach a lot since it allows for easy interception of data exchanged between the grid and the ORM. I recommend you give it a try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文