WCF 数据服务操作丢失 Silverlight 客户端中子实体的顺序
我有一个 WCF DataService 操作,它公开 Businesses
和 Customers
。
在服务器端,我按姓氏对每个企业的客户进行排序,如下所示:
List<Customers> orderedCustomers = business.Customers.OrderBy(c=> c.LastName).ToList<Customers>()
business.Customers.Clear()
foreach (Customers customer in orderedCustomers )
business.Customers.Add(customer )
在客户端(在 Silverlight 中异步),我像这样扩展每个企业的客户:
Context.BeginExecute<Business>(new Uri(serviceurl + BeginGetAllBusinessData&$expand=Cutomers, UriKind.Relative), GettingBusinessDataCompleted, Context);
我的问题是:企业中的客户未在客户端上排序端(它们在服务器端排序)。我为 OrderBy 选择的任何字段都会发生同样的情况。看起来序列化选择了自己的顺序。我想在服务器端对它们进行排序。
我是不是漏掉了什么???
I have a WCF DataService operation, which exposes Businesses
and Customers
.
On the server side, I sort each Business's Customers by LastName, this way:
List<Customers> orderedCustomers = business.Customers.OrderBy(c=> c.LastName).ToList<Customers>()
business.Customers.Clear()
foreach (Customers customer in orderedCustomers )
business.Customers.Add(customer )
And on the client side (asynchronously, in Silverlight), I expand each business's customers like this:
Context.BeginExecute<Business>(new Uri(serviceurl + BeginGetAllBusinessData&$expand=Cutomers, UriKind.Relative), GettingBusinessDataCompleted, Context);
My issue is: The customers in businesses are not sorted on the client side (they are sorted server-side). It happens the same with any field I choose for the OrderBy. Looks like serialization chooses its own order. I'd like to sort them on the server side.
Am I missing something???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定返回的列表是乱序的吗?如果您的
GettingBusinessDataCompleted
回调负责将扩展内容添加到 UI,那么事情可能会出现乱序。不保证异步操作按照开始的顺序完成。
Are you sure the returned List is out of order? If your
GettingBusinessDataCompleted
callback is responsible for adding the expanded content to the UI then things can appear out of sequence.Asynchronous operations are not guaranteed to complete in the order they were begun.