During some tests with RavenDb I receive a JsonSerializationException during the serialization of my object. The error is:
{"Self referencing loop detected for type
'System.Collections.Generic.List`1[RavenDbTest.Category]'."}
The class that I try to save is the following:
[JsonObject( IsReference = true )]
public class Category
{
public Guid Id { get; set; }
public string Name { get; set; }
public Category Parent { get; set; }
public IList<Category> Children { get; set; }
public Category()
: base()
{
Children = new List<Category>();
}
public void Add( Category category )
{
category.Parent = this;
Children.Add( category );
}
public override Boolean Equals( Object obj )
{
return true;
}
}
I have added the JsonObject attribute in order to avoid self reference
error. The problem arise when I override the Equals method and
returing always true.
Of course this is a unreal implementation, but I have a project where
the same error arise.