使用 WCF 数据服务进行分页 [英] Paging with WCF data service

查看:25
本文介绍了使用 WCF 数据服务进行分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于如何使用 WCF 数据服务处理分页.我想使用它的方式是执行查询(传递页面大小和当前页面),并获取该查询的结果以及页面总数、当前页码和页面大小等分页信息.此分页信息由客户端(这是另一个服务,用于将结果转换为 JSON 以供使用它的移动应用程序使用)来处理下一个/上一个按钮.

My question is about how you handle paging with a WCF data service. The way I want to use it, is execute a query (passing page size and current page), and get back the results of that query and also the paging information like total number of pages, current page number and page size. This paging information is used by the client (which is another service that transforms the result to JSON for a mobile application that consumes it) to handle next/previous buttons.

但是,在 WCF 数据服务上使用 LINQ 太有限了,它不支持我需要的 LINQ 表达式.

However, using LINQ on a WCF data service is too limited, it doesn't support the LINQ expression I need.

我尝试在 WCF data 服务中创建服务操作,但我只能返回数据实体的 IQueryable 集合,因此我无法返回也包含分页信息的自定义实体.

I tried creating a service operation in the WCF data service, but I can only return IQueryable collections of data entities, so I cannot return a custom entity that also contains paging information.

有没有办法为 WCF 数据服务实现分页,以便在结果旁边我也能得到分页信息?

Is there a way to do implement paging for a WCF data service so that I next to the result I also get back paging information?

由于WCF数据服务的限制,我切换到了普通的WCF服务.老实说,我不明白为什么有人会想要使用具有这些严重限制的数据服务!

because of the limitations of WCF data services, I switched to a normal WCF service. To be honest, I don't see why anyone would ever want to use a data service with these severe limitations!

推荐答案

很遗憾,WCF 数据服务似乎太有限了,我的解决方案是切换到常规 WCF 服务,以便我可以使用完整的 LINQ 和自己定义数据契约.

Unfortunately it seems that WCF data services is way too limited, and the solution for me was to switch to a regular WCF service so that I could use full LINQ and define data contracts myself.

这篇关于使用 WCF 数据服务进行分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆