Skip to content

Instantly share code, notes, and snippets.

@mdissel
Created March 31, 2012 17:48
Show Gist options
  • Save mdissel/2267078 to your computer and use it in GitHub Desktop.
Save mdissel/2267078 to your computer and use it in GitHub Desktop.
Modelling File Folder hiearchy using RavenDb
public interface INamedEntity
{
string Id { get; set; }
string Name { get; set; }
}
public class DenormalizedReference<T> where T : INamedEntity
{
public string Id { get; set; }
public string Name { get; set; }
public static implicit operator DenormalizedReference<T>(T doc) {
return new DenormalizedReference<T> {
Id = doc.Id,
Name = doc.Name
};
}
}
public interface IFolderItem: INamedEntity
{
DenormalizedReference<IFolder> Parent { get; set; }
}
public interface IFolder: IFolderItem
{
IList<DenormalizedReference<IFolderItem>> Items {get;set;}
}
public class Folder : IFolder
{
public string Id { get; set; }
public string Name { get; set; }
public DenormalizedReference<IFolder> Parent { get; set; }
public IList<DenormalizedReference<IFolderItem>> Items {get;set;}
}
public class File : IFolderItem
{
public string Id { get; set; }
public string Name { get; set; }
public DenormalizedReference<IFolder> Parent { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment