Note that there are some explanatory texts on larger screens.

plurals
  1. POBreezejs Uncaught TypeError: Converting circular structure to JSON
    primarykey
    data
    text
    <p>I have an ASP.Net MVC SPA using the Hot Towel template i.e. breezejs, knockout, entity framework (code first), durandal etc.</p> <p>In my EF model I have a class named "Section" that has a self referencing association. Each section belongs to a "Document" and each Section also has a collection of "Items":</p> <pre><code> public class Section : CommonBase { ... public Guid DocumentId { get; set; } public Document Document { get; set; } ... public List&lt;Item&gt; Items { get; set; } public Guid? ParentId { get; set; } public Section Parent { get; set; } public List&lt;Section&gt; Children { get; set; } ... } public class Item : CommonBase { ... public Guid SectionId { get; set; } public Section Section { get; set; } ... } </code></pre> <p>I load the "Sections" and "Items" when I load the documents via a Breeze query and a BreezeController method:</p> <pre><code> var query = breeze.EntityQuery.from(model.entitySets.document) .where(predicate) .expand("sections.items.cloudDriveFile, sections.cloudDriveFile") .orderBy(model.orderByClauses.document); return _contextProvider.Context.Documents.Where(x =&gt; x.OrganisationId == currentUser.OrganisationId); </code></pre> <p>If I edit and save a "Section" without loading any "Items" then all works OK. However when I try to edit and save a section that has "Items" - and I have loaded those "Items" (either using an Include in the BreezeController or an Expand in javascript) - then I get the following error:</p> <p>"Uncaught TypeError: Converting circular structure to JSON "</p> <p>I am saving using a simple call to manager.saveChanges().</p> <p>Is there some technique or pattern that I should be implementing to avoid this circular reference error?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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