1

I'm using a legacy database that has some cyclic references. When I consume my Ria service from a SL4 client. (generated entities through my ORM mapper) I get the following error:

There was an error while trying to serialize parameter http://tempuri.org/:GetPublicationPagesResult. The InnerException message was 'Object graph for type 'xxx.Entities.TblPublicationPage' contains cycles and cannot be serialized if reference tracking is disabled.

[Query]
public IQueryable<TblPublicationPage> GetPublicationPages(int publicationId)
{
    return this.PublicationLogic.Value.GetPublicationPages(publicationId);
}

I know how to enable it for plain WCF through CyclicReferencesAware attribute or IsRefence=true. But I can't figure out how to do this with WCF Ria Services.

krikke999
  • 33
  • 4

2 Answers2

0

I now understand WCF Ria Services better, I just tried to fix it like I would do it in plain WCF and added a metadataclass to my generated entities:

[DataContract(IsReference = true)]
[DataServiceKey("PublicationPageID")]
[DebuggerDisplay("PublicationPageID: {PublicationPageID}")]
[MetadataType(typeof(TblPublicationPageMetadata))]
public partial class TblPublicationPage
{
    internal sealed class TblPublicationPageMetadata
    {
        [DataMember]
        public int PublicationPageID { get; set; }
    }
}

Only disadvantages at this point is I have to decorate every property in the metadata class with a [DataMember] attribute...

krikke999
  • 33
  • 4
0

Use [CyclicReferencesAware(true)]

NoWar
  • 36,338
  • 80
  • 323
  • 498