In memory IContentRepository – The genealogy of pages

This post is part of a series of post where I try to implement an in memory IContentRepository. The tests for this posts are found here and here.

This post will look at the last members of the IContentLoader interface for a while, namely GetDescendents and GetAncestors.

IEnumerable<ContentReference> GetDescendents(ContentReference contentLink);
IEnumerable<IContent> GetAncestors(ContentReference contentLink);

First thing that pop out is that Descendents returns a enumerable of ContentReference while ancestors returns an enumerable of IContent.

The happy path – GetDescendents

Not much to say about these methods since they are pretty self explanatory. GetDescendents return a list of content reference to the descendents of the sent in content reference. What is kind of interesting is the order in which these pages are returned. As far as I can tell they are returned in reverse hierarchy. That is, say we have the followin structure (page IDs) under the page we call GetDescendents from


The resulting enumerable would have the order P7, P6 (represents hierarchy level 3), P5, P4, P2 (represents hierarchy level 2), P3, P1 (represents hierarchy level 1).

The happy path – GetAncestors

The ancestors are returned in the order of closest distance to the page requested up until the root page. So given the following structure


when requesting ancestors for P3 it would return the pages P2, P1, root.