Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- namespace ConsoleBlog.Models
- {
- public class Post
- {
- private ICollection<PostAnswer> answers;
- private ICollection<Tag> tags;
- public Post()
- {
- this.answers = new HashSet<PostAnswer>();
- this.tags = new HashSet<Tag>();
- }
- //primary key
- [Key]
- public int PostId { get; set; }
- [Required] //set to not nulluble
- public string Title { get; set; }
- [Column("New Name")]
- public string Content { get; set; }
- [NotMapped]
- public DateTime CreatedOn { get; set; }
- //foreign key
- [ForeignKey("Category")]
- public int CategoryId { get; set; }
- //navigation property
- public virtual Category Category { get; set; }
- public virtual ICollection<PostAnswer> Answers
- {
- get { return this.answers; }
- set { this.answers = value; }
- }
- public virtual ICollection<Tag> Tags
- {
- get { return this.tags; }
- set { this.tags = value; }
- }
- public PostType Type { get; set; }
- [Timestamp]
- public byte[] RowVersion { get; set; }
- //includes propertiest from this class(class have [ComplexType])
- public PostDetail Detail { get; set; }
- }
- }
- namespace ConsoleBlog.Models
- {
- [ComplexType]
- public class PostDetail
- {
- public string CreatedByUser { get; set; }
- public bool IsDeleated { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment