Created
March 31, 2012 17:48
-
-
Save mdissel/2267078 to your computer and use it in GitHub Desktop.
Modelling File Folder hiearchy using RavenDb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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