If you save the recycle bin, you will get the "Autodrome Discovered" exception ... when called SaveChanges().
Easy to fix. You add the attribute [JsonObject(IsReference = true)]to the cart. This says the serializer saves the Item Cart as a link instead of a new object.
[JsonObject(IsReference = true)]
public class Cart
{
public List<Item> Items = new List<Item>();
}
public class Item
{
public Cart Cart;
}
, . , .
var cart = new Cart();
cart.Items.Add(new Item { Cart = cart });
session.Store(cart);
session.SaveChanges();
...
var cart = session.Query<Cart>().First();
Assert.ReferenceEquals(cart, cart.Items.First().Cart);