开发者

Silverlight RIA hierarchical model not returning child elements

I ham developing a Silverlight RIA solution that needs to return a hierarchical model from the server which is declared as below.

Imports System.ComponentModel.DataAnnotations
Imports System.Collections.Generic
Imports System.Runtime.Serialization

<DataContract()>
Public Class Concerns

    <Key()>
    <DataMember()>
    Propert开发者_运维问答y ID As Integer
    <DataMember()>
    Property ParentID As Integer
    <DataMember()>
    Property IssueID As String
    <DataMember()>
    Property Version As Integer
    <DataMember()>
    Property ShortDescription As String
    <DataMember()>
    Property DetailedDescription As String
    <DataMember()>
    Property OriginatingDepartment As String
    <DataMember()>
    Property OriginatingBusinessUnit As String
    <DataMember()>
    Property BusinessUnitAffected As String
    <DataMember()>
    Property ProjectModel As String
    <DataMember()>
    Property Category As String
    <DataMember()>
    Property Priority As Integer
    <DataMember()>
    Property ApprovalStatus As Integer
    <DataMember()>
    Property ProductLifeCycle As String
    <DataMember()>
    Property ListItemID As Integer
    <DataMember()>
    Property CreateDate As Date
    <DataMember()>
    Property CreateBy As String
    <DataMember()>
    Property EditedDate As Date
    <DataMember()>
    Property EditedBy As String
    <DataMember()>
    <Association("Concerns", "ID", "ParentID")>
    Property History As New List(Of Concerns)

End Class

The issue I have is that although the History property is populated server side when returned to the Silverlight client as a ReadOnlyObservableCollection the History property does not come over.

I have tried flagging the class with the <CollectionDataContract()> annotation but nothing returns.

EDIT: Following Jehof post the History property now returns across the service but the data populated in the History collection does not appear client side.

Any idea what I am missing?

Phil


You need to define a Association between Concerns and and its containing Concerns (Parent-Child-Structure). To do that you need to decorate the History property with the AssociationAttribute. Also you must add a property ParentId to your Concerns class that will be used in the Association.

<DataContract()>
Public Class Concerns

  <Key()>
  <DataMember()> _
  Property ID As Integer

  <DataMember()> _
  Property ParentID As Integer

  <DataMember()> _
  <Association("Concerns", "ID", "ParentID")>_
  <Include()> _
  Property History As New List(Of Concerns)

End Class
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜