Search code examples
db4o

Db4o Tree structure C#


I'm new to db4o and i'm trying to figure out if it's possible to do the following:

public class Page
{ 
    public Guid ID {get;set;}
    public Page Parent {get;set;}
    public IList<Page> Children {get;set;}
    public String Name {get;set;}
    public String Depth {get;set;}
}

When I save the page i have it's parent only. IE

Page p1 = new Page() { 
    ID = Guid.NewGuid(),
    Name = "p1",
    Parent = null
};
Page p2 = new Page() { 
    ID = Guid.NewGuid(),
    Name = "p2",
    Parent = p1
};
Page p3 = new Page() { 
    ID = Guid.NewGuid(),
    Name = "p3",
    Parent = p1
};

When i load up p1 is there anyway to populate the two children??


Solution

  • Db4O will load also the collection of children as soon as you load p1 from the datastore, so yes it's possible...