Note that there are some explanatory texts on larger screens.

plurals
  1. POSolve a circular reference in WCF from my POCOs
    text
    copied!<p>I have a couple of classes (for now) and I'm trying to clear up a circular reference between the two since it is killing WCF's serialization.</p> <p>I am using EF with POCOs in a WCF REST service is that helps. I have simplified my problem down to bare bones for an easy example here:</p> <pre><code>[ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Groups { [WebGet(UriTemplate = "")] public Message GetCollection() { var message = new Message { Body = "Test message" }; var group = new Group { Title = "Title of group" }; message.Group = group; group.Messages = new List&lt;Message&gt; { message }; return message; } } public class Message { public string Body { get; set; } public Group Group { get; set; } } [DataContract(IsReference = true)] public class Group { public string Title { get; set; } public ICollection&lt;Message&gt; Messages { get; set; } } </code></pre> <p>I have added the <code>[DataContract(IsReference = true)]</code> to the Group class so that the circular reference is cleaned up however my returned results end up like this:</p> <pre><code>&lt;Message xmlns="http://schemas.datacontract.org/2004/07/LmApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;Body&gt;Test message&lt;/Body&gt; &lt;Group z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/"/&gt; &lt;/Message&gt; </code></pre> <p>Where are the properties of the Group and how can I get them?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload