In my application I have Folders that can contain other Folders. They have all sorts of properties like this:
public class Folder
{
public Folder()
{
Sets = new Collection<Set>();
Folders = new Collection<Folder>();
Stage = Stage.one;
IsArchived = false;
DateCreated = DateTime.Now;
}
// Primitive Properties
[Required]
[Key]
public virtual int FolderId { get; set; }
public virtual int? ParentFolderId { get; set; }
[ForeignKey("ParentFolderId")]
public virtual Folder ParentFolder { get; set; }
[Required]
public int UserId { get; set; }
[Required]
public virtual string Title { get; set; }
public virtual string Details { get; set; }
[Required]
public virtual Stage Stage { get; set; }
[Required]
public virtual bool IsArchived { get; set; }
[Required]
public virtual DateTime DateCreated { get; set; }
[ForeignKey("FolderId")]
public virtual ICollection<Set> Sets { get; set; }
[ForeignKey("ParentFolderId")]
public virtual ICollection<Folder> Folders { get; set; }
}
Now, each User of the application has a "Home Folder" - a starting point. The Home Folder doesn't need half of the above properties however. I figure I have two options:
1) Use this entity and just add "isHomeFolder" as a property. This is simple but means I'll be sending blank [Required] properties over the wire for JSON requests - Home Folders don't have a title, can't be archived, etc.
2) Create another entity with just the required fields and duplicate the required properties there. This just doesn't seem very DRY, but feels better than the first option.
As a beginner programmer I'm not sure if there are any other options. Is there a standard approach/solution here?
In case it matters, I'm building on Entity Framework Code-First + WebAPI.