序列化 LinqtoNh 过滤/排序子句

发布于 2024-12-16 13:55:03 字数 165 浏览 1 评论 0原文

我有一个 REST Web 服务,它使用 LinqtoNh 来查询实体并将它们作为 DTO(简单的经典内容)返回。我希望该服务对返回的实体应用一些过滤/排序子句,并且我询问是否有某种方法可以序列化 linqtonh 表达式,以便将其发送到线路而不创建一些自定义策略。优点是客户端上没有 NH 参考。 有什么建议吗?

I've got a REST web service that uses LinqtoNh to query entities and return them as DTO, plain classical stuff. I want the service to apply some filter/order clause on the returned entities, and I'm asking if there is some way of serialize the linqtonh expression in order to send it an the wire without creating some custom strategy. A plus would be not having a NH reference on the client.
Any suggestion?

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

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

发布评论

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

评论(1

锦欢 2024-12-23 13:55:03

看一下 WCF Ria 服务:它公开了一个 WCF Rest 服务,支持 LINQ 过滤、排序、分页和分组。
服务器端 DomainService 将创建一个 LINQ 查询,其中包含“Where”、“Order*”、“Take”、“Skip”...
避免 NH 引用是个好主意,实现您自己的 IQueryable,将其链接到 NHibernate(也许您想使用 IoC 引擎来执行此操作)并在公开的查询中返回它!你快完成了,大多数 LINQ2NH 调用都是标准的 LINQ 扩展方法,如果你需要使用急切的获取扩展方法 (Fetch*) 或其他漂亮的 NHibernate 东西,你将不得不编写其他东西。
就客户端而言,WCF Ria 最初是为 SL 设计的,但支持一切,他们甚至有名为 RIA/JS

Take a look at WCF Ria Services: It expose a WCF Rest service that supports the LINQ filtering, sorting, paging e grouping.
Server side the DomainService will create a LINQ query with "Where", "Order*", "Take", "Skip"...
Avoiding the NH reference it's a great idea, implement your own IQueryable, link it to NHibernate (maybe you want to use an IoC engine to do so) and return it in the exposed queries! You're almost done, most of the LINQ2NH call are standard LINQ extensions method, you would have to write somethign else if you need to use the eager fetching extension method (Fetch*) or other pretty NHibernate-stuff.
As far the client, WCF Ria is initially designed for SL but supports everything, they have even JS client called RIA/JS

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