我一直在尝试使用 WCF 并编写了一个 WCF 服务来为网站提供后端。在实现服务器端分页时,我遇到了一个问题,就像我找到的所有示例一样(例如 http://msdn.microsoft.com/en-us/library/ee358711.aspx)似乎都使用 DataServiceQueryContinuation 和 WCF Data服务。
虽然我很感激我可以编写一个 WCF 数据服务来返回数据,但使用 WCF 服务来处理登录和更新用户信息之类的事情,然后使用单独的 WCF 数据服务来处理更大的查询/报告,这似乎会带来额外的复杂性。
这是标准做法还是有内置机制通过 WCF 服务的方法调用来分页数据?
编辑
我发现了几种可能的方法来执行此操作,一种涉及 Linq 的 skip
和 take
运算符的简单方法:通过WCF服务实现寻呼机
还有一个更复杂的方法:
处理大量数据的 WCF 服务的最佳实践?< /a>
我曾想过可能有一种方法可以使用 WCF 服务来分页数据,就像使用 WCF 数据服务一样: http://msdn.microsoft.com/en-us/library/ee474245.aspx< /a>
有谁知道这是否可能?
I've been experiementing with using WCF and have written a WCF Service to provide the backend for a web site. I've encountered a problem when it comes to implementing server-side paging as all the examples I've found (such as http://msdn.microsoft.com/en-us/library/ee358711.aspx) all seem to use DataServiceQueryContinuation and WCF Data Services.
Whilst I appreciate I could write a WCF Data Service to return the data, it seems like extra complexity having a WCF Service for things like logins and updating user information and then a separate WCF Data Service for larger queries / reporting.
Would this be the standard practise or is there a built in mechanism for paging data via a method call from a WCF service?
EDIT
I've found a couple of possible methods of doing this, a simple method involving Linq's skip
and take
operators: Implementing pager through WCF service
and a more complicated method:
Best practice for WCF service with large amounts of data?
I had thought that there might be a way of using WCF Service to page data like you can with a WCF Data Service: http://msdn.microsoft.com/en-us/library/ee474245.aspx
Does anyone know if this is possible?
发布评论
评论(1)
我们使用 WCF 服务与后端服务器进行所有通信,并且通过将简单的 PaginDTO 传递到具有 PageSize 和 CurrentPageIndex 等属性的方法调用来实现分页。
结果是一个 PagedDTO,其中包含项目列表和有关页面总数的信息。
我们为数据库使用实体框架,并且通过 Skip/Take 实现起来非常简单。
希望这有帮助:)
We are using a WCF service for all our communication with our back end server and we've implemnted paging by just passing a simple PaginDTO to a method call with properties like PageSize and CurrentPageIndex.
The result is a PagedDTO which contains the list of items and info about the total amount of pages.
We use the entity framework for our database and with Skip/Take this is really simple to implement.
Hope this helps :)