private static void PrepareDeepObjGraph() { using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { Person jodie = new Person("Jodie"); jodie.Add(new Person("Joanna")); jodie.Add(new Person("Julia")); container.Store(jodie); container.Store(new Car(new Person("Janette"), "Mercedes")); } }
private static void UpdateDepthForCollection() { // #example: A higher update depth fixes the issue IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration(); config.Common.UpdateDepth = 2; using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { // #end example Person jodie = QueryForJodie(container); jodie.Add(new Person("Jamie")); container.Store(jodie); } config = Db4oEmbedded.NewConfiguration(); config.Common.UpdateDepth = 2; using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { Person jodie = QueryForJodie(container); foreach (Person person in jodie.Friends) { // the added friend is gone, because the update-depth is to low Console.WriteLine("Friend=" + person.Name); } } }
private static void ToLowUpdateDepthOnCollection() { // #example: Update doesn't work on collection using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { Person jodie = QueryForJodie(container); jodie.Add(new Person("Jamie")); // Remember that a collection is also a regular object // so with the default-update depth of one, only the changes // on the person-object are stored, but not the changes on // the friend-list. container.Store(jodie); } using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { Person jodie = QueryForJodie(container); foreach (Person person in jodie.Friends) { // the added friend is gone, because the update-depth is to low Console.WriteLine("Friend=" + person.Name); } } // #end example }
private static void PrepareDeepObjGraph() { using (IObjectContainer container = Db4oEmbedded.OpenFile(DatabaseFile)) { Person jodie = new Person("Jodie"); jodie.Add(new Person("Joanna")); jodie.Add(new Person("Julia")); container.Store(jodie); container.Store(new Car(new Person("Janette"), "Mercedes")); } }