从服务器到客户端的 Ria 数据损坏

发布于 2024-11-18 00:18:04 字数 3427 浏览 2 评论 0原文

我在 Silverlight 4 Ria 项目的服务器端有一个 Linq 查询,它根据时间段(月)返回许多不同的项目。

我遇到的问题是,当客户端回调触发时,数据已损坏,并且从服务器返回的所有项目都是集合中最后一个项目的重复项。

服务器调用

Public Function GetBusinessHeadCountHistory(ByVal businessUnit As String) As IEnumerable(Of EngineeringHeadCountBusinessHistory)
        Return From t In ObjectContext.tblTimes
                     Join h In ObjectContext.tblEngineeringDashboard_CADMachinesCounts On t.ID Equals h.TimeID
                     Join b In ObjectContext.tblEngineeringDashboard_Business On h.BusinessID Equals b.ID
                           Where b.BusinessUnit = businessUnit
                           Order By t.Period
                           Select New EngineeringHeadCountBusinessHistory With {.Month = t.Period, .BusinessUnit = b.BusinessUnit, .HeadCount = h.Count}
End Function

客户端回调

Public Property EngineeringBusinessHistoryCount As ReadOnlyObservableCollection(Of EngineeringHeadCountBusinessHistory)
    Get
        Return _engineeringBusinessHistoryCount
    End Get
    Set(ByVal value As ReadOnlyObservableCollection(Of EngineeringHeadCountBusinessHistory))
        _engineeringBusinessHistoryCount = value
        IsBusinessCountBusy = False
        RaisePropertyChanged("ChildReportTitle")
        RaisePropertyChanged("EngineeringBusinessHistoryCount")
    End Set
End Property

我已经确认来自服务器和 LinqPad 中的 Linq 查询是正确的。

有什么想法吗?

编辑:Fiddler RAW 回复

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 1738
Content-Type: application/msbin1
Expires: -1
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Date: Thu, 30 Jun 2011 11:08:47 GMT

@#GetBusinessHeadCountHistoryResponsehttp://tempuri.org/@!GetBusinessHeadCountHistoryResult aDomainServices i)http://www.w3.org/2001/XMLSchema-instance^
TotalCount�^
RootResults b<http://schemas.datacontract.org/2004/07/EngineeringDashboard_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month����~�X�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@���p�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@DE��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month���hE��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month���w`ض�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@E�4��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month����{���_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month���x�#��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month��@F��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month�����/�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month���y�nG�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month�����_�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month�����]w�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month���z���_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month���
����_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month��@����

Phil

I have a Linq query on the server side of a Silverlight 4 Ria project that returns a number of distinct items based on a time period(Month).

The problem I am getting is when the client callback fires the data has been corrupted and all the items returned from the server are duplicates of the last item in the collection.

Server Call

Public Function GetBusinessHeadCountHistory(ByVal businessUnit As String) As IEnumerable(Of EngineeringHeadCountBusinessHistory)
        Return From t In ObjectContext.tblTimes
                     Join h In ObjectContext.tblEngineeringDashboard_CADMachinesCounts On t.ID Equals h.TimeID
                     Join b In ObjectContext.tblEngineeringDashboard_Business On h.BusinessID Equals b.ID
                           Where b.BusinessUnit = businessUnit
                           Order By t.Period
                           Select New EngineeringHeadCountBusinessHistory With {.Month = t.Period, .BusinessUnit = b.BusinessUnit, .HeadCount = h.Count}
End Function

Client Callback

Public Property EngineeringBusinessHistoryCount As ReadOnlyObservableCollection(Of EngineeringHeadCountBusinessHistory)
    Get
        Return _engineeringBusinessHistoryCount
    End Get
    Set(ByVal value As ReadOnlyObservableCollection(Of EngineeringHeadCountBusinessHistory))
        _engineeringBusinessHistoryCount = value
        IsBusinessCountBusy = False
        RaisePropertyChanged("ChildReportTitle")
        RaisePropertyChanged("EngineeringBusinessHistoryCount")
    End Set
End Property

I have confirmed that the Linq query is correct from the server and in LinqPad.

Any ideas??

EDIT : Fiddler RAW repsonse

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 1738
Content-Type: application/msbin1
Expires: -1
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Date: Thu, 30 Jun 2011 11:08:47 GMT

@#GetBusinessHeadCountHistoryResponsehttp://tempuri.org/@!GetBusinessHeadCountHistoryResult aDomainServices i)http://www.w3.org/2001/XMLSchema-instance^
TotalCount�^
RootResults b<http://schemas.datacontract.org/2004/07/EngineeringDashboard_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month����~�X�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@���p�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@DE��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month���hE��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month���w`ض�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month��@E�4��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�_Month����{���_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month���x�#��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month��@F��_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount� _Month�����/�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month���y�nG�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month�����_�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�"_Month�����]w�_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month���z���_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month���
����_#EngineeringHeadCountBusinessHistory_BusinessUnit�
skid-steer_ HeadCount�$_Month��@����

Phil

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

淡水深流 2024-11-25 00:18:04

首先,使用 Fiddler 检查原始服务器响应是否正确。

First, use Fiddler to check wether raw server response is correct ot not.

深空失忆 2024-11-25 00:18:04

问题在于 POCO 类 Key 注释位于非唯一字段上。我已将其更改为独特的 Month 属性,现在它按预期工作。

但奇怪的错误...

Imports System.ComponentModel.DataAnnotations
Imports System.Runtime.Serialization

Public Class EngineeringHeadBUHistory

    '<Key()>
    '<DataMember()> _
    'Property BusinessUnit As String
    <Key()>
    <DataMember()>
    Property Month As Date
    <DataMember()> _
    Property HeadCount As Integer

End Class

The problem was down to the POCO class Key annotation being on a non-unique field. I have changed it around to the unique Month property and it now works as expected.

Strange error though...

Imports System.ComponentModel.DataAnnotations
Imports System.Runtime.Serialization

Public Class EngineeringHeadBUHistory

    '<Key()>
    '<DataMember()> _
    'Property BusinessUnit As String
    <Key()>
    <DataMember()>
    Property Month As Date
    <DataMember()> _
    Property HeadCount As Integer

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