WCF 数据服务操作丢失 Silverlight 客户端中子实体的顺序

发布于 2024-12-01 12:49:46 字数 728 浏览 1 评论 0原文

我有一个 WCF DataService 操作,它公开 BusinessesCustomers

在服务器端,我按姓氏对每个企业的客户进行排序,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜宝宝 2024-12-08 12:49:46

您确定返回的列表是乱序的吗?如果您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文