Created
October 6, 2013 23:58
-
-
Save mikecole/6860676 to your computer and use it in GitHub Desktop.
Customization with Data Annotations
This file contains 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
[Table("Author")] | |
public class Author : EntityBase | |
{ | |
public Author() | |
{ | |
Posts = new Collection<Post>(); | |
} | |
[Required] | |
[StringLength(50)] | |
public string Name { get; set; } | |
[StringLength(50)] | |
public string TwitterHandle { get; set; } | |
public virtual ICollection<Post> Posts { get; set; } | |
public int JobTitleID { get; set; } | |
[ForeignKey("JobTitleID")] | |
public virtual JobTitle JobTitle { get; set; } | |
} | |
[Table("Category")] | |
public class Category : EntityBase | |
{ | |
public Category() | |
{ | |
Posts = new Collection<Post>(); | |
} | |
[Required] | |
[StringLength(50)] | |
public string Name { get; set; } | |
public virtual ICollection<Post> Posts { get; set; } | |
} | |
[Table("JobTitle")] | |
public class JobTitle : EntityBase | |
{ | |
public JobTitle() | |
{ | |
Authors = new Collection<Author>(); | |
} | |
[Required] | |
[StringLength(50)] | |
public string Title { get; set; } | |
public virtual ICollection<Author> Authors { get; set; } | |
} | |
[Table("Post")] | |
public class Post : EntityBase | |
{ | |
[Required] | |
[StringLength(150)] | |
public string Title { get; set; } | |
public string Url { get; set; } | |
public int AuthorID { get; set; } | |
[ForeignKey("AuthorID")] //For real? Bleh... | |
public virtual Author Author { get; set; } | |
public int PostCategoryID { get; set; } | |
[ForeignKey("PostCategoryID")] | |
public virtual Category Category { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment