集合属性的排序
我在 ADO.NET 实体数据模型上使用 WCF 数据服务,并且有一个带有“订单”集合的“客户”对象。
我有一个 SINGLE 查询,它返回 Customer 对象,并嵌入了 Orders 集合。
如何通过 OData URI(或实际上的任何机制)指定我希望“Orders”集合按特定属性排序?
我的 Order 对象的 PK 是一个 Guid,所以如果我只是依赖数据库订单,我基本上会在我的 Orders 集合上返回一个随机订单,这不太理想......
注意:这必须通过单个查询完成,我不想查询客户,然后必须再次查询订单。
谢谢
I am using WCF Data Services over an ADO.NET Entity Data Model, and I have a 'Customer' object with 'Orders' collection.
I have a SINGLE query which returns the Customer object, with an embedded Orders collection.
How do I specify, through an OData URI (or any mechanism, in fact), that I want the 'Orders' collection to be sorted by a particular property?
My PK for my Order object is a Guid, so if I simply rely on database order, I basically get back a random order on my Orders collection, which is less than ideal...
Note: This must be done with a single query, I dont want to query for the customer, then have to query again for the orders.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OData 协议目前没有办法做到这一点。
您可能会尝试使用服务操作来为您运行查询,但随后它必须返回 IQueryable,并且客户端仍然需要请求 $expand(因为您无法在服务器上自动扩展)。不确定这是否适用于 EF 提供商,但可能会。
OData protocol currently doesn't have a way to do this.
You might try to use service operations to run the query for you, but then it would have to return IQueryable and the client would still need to ask for the $expand (since you can't auto-expand on the server). Not sure if this would work for EF provider, but it might.