OData 服务和 Silverlight 客户端分页,我是否遗漏了什么?
我有一个 silverlight 应用程序,在其中使用 MVVM 方法并从 oData 服务检索数据。我想要做的是使用内置的数据网格和数据分页器控件来显示和移动返回的数据。经过几个小时的研究,我觉得没有好的内置方法可以做到这一点。我认为这需要我自己编写一些自定义分页并构建分页查询。我能找到的有关 PagedCollectionView 的所有内容似乎都表明它仅适用于已缓存在客户端的数据。由于我不想立即从 oData 服务中提取数千条记录,因此这是行不通的。我在这里缺少什么吗? DataServiceCollection 固有的东西或者允许我让数据分页器自动处理构建查询的东西?
I've got a silverlight application where I'm using the MVVM approach and retriving data from an oData service. What I'm wanting to do is use the built in data grid and data pager controls to display and move through the returned data. After a couple hours of research, I feel like there is no good built in way to do this. I think it is going to require me writing some custom paging and building my paged queries by myself. Everything I can find about the PagedCollectionView seems to indicate it only works on data that is already cached on the client side. Since I don't want to pull thousands of records from the oData service at once, that won't work. Is there something I'm missing here? Something inherant about the DataServiceCollection or something that allows me to let the data pager handle building the queries automatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个自定义实现,它修改 OData 查询以支持分页 http://blogs.msdn.com/b/phaniraj/archive/2010/08/19/implementing- server-side-sorting-paging-for-odata-feeds-in-silverlight-controls-datagrid-datapager-dataform.aspx
这篇文章不太好,但经过一番摆弄(删除框架并添加DataGridSupport 作为 UserControl,并使 NewItemPlaceholderPosition 属性自动实现)我确实让他的源代码可以工作。这是相当令人印象深刻的http://cid-925c2d2bb2d03c6b.office.live。 com/self.aspx/Public/EuphoriaClientApp.zip
Here's a custom implementation, it modifies the OData query to support paging http://blogs.msdn.com/b/phaniraj/archive/2010/08/19/implementing-server-side-sorting-paging-for-odata-feeds-in-silverlight-controls-datagrid-datapager-dataform.aspx
The article wasn't too great, but after some fiddling (removing the Frame and just adding DataGridSupport as a UserControl, and making the NewItemPlaceholderPosition property auto-implemented) I did got his source code to work. It's pretty impressive http://cid-925c2d2bb2d03c6b.office.live.com/self.aspx/Public/EuphoriaClientApp.zip
这是外部 OData 服务,还是在您自己的服务器上?
如果使用您自己的服务,请改用 RIA 服务。然后分页就很简单了。
如果在另一台服务器上,无论如何都要实现 RIA 服务,但让您的服务器以分页方式获取 Odata,并通过 RIA 服务 linq 查询返回。
如果您可以提供有关数据服务和服务器设置的更具体详细信息,我将尝试提供具体详细信息。
Is that an external OData service, or on your own server?
If on your own service, use RIA services instead. Then paging is trivial.
If on another server, implement RIA services anyway, but get your server to fetch the Odata, in a paged fashion, and return via RIA services linq queries.
If you can provide more specific details of the data service and your server setup I will try provide specific details.