In a grails application, the following structure is completely supported and persisted on mongodb (using mongodb plugin):
class Person {
String name
static hasMany = [pets: Pet]
}
class Pet {
String name
Person owner
}
The relation is traverse-able in both ways. I need to implement the exact same structure in C# (using mongodb official driver for C#). How is it possible to have both sides reachable from the other side. In C#, circular dependencies are not serializable and I could not find any alternative way.
Change child side to using an ObjectID ref to owner and make a custom transient getter getOwner() that fetches the owner based on the owner_id. Very easy to do in grails, should facilitate easy serialization in c#.