Я использую ядро EF, и мне нужен совет, как правильно создать таблицу.Есть статья, это можно прокомментировать.Также есть возможность комментировать сами комментарии.Как описать сущности для базы данных?
Итак:
public class Article
{
public int Id {get; set;}
public string Content {get; set;}
public List<CommentForArticle>Comments{get;set;}
}
public class CommentForArticle
{
public int Id {get; set;}
public string Content {get; set;}
public List<CommentForComment> Comments {get; set;}
public int ArticleId {get; set;}
public Article Artcile {get; set;}
}
public class CommentForComment
{
public int Id {get; set;}
public string Content {get; set;}
public int CommentId {get; set;}
public CommentForArticle CommentForArticle{get; set;}
}
Или так:
public class Article
{
public int Id {get; set;}
public string Content {get; set;}
public List<Comment>Comments{get; set;}
}
public class Comment
{
public int Id {get; set;}
public string Content {get; set;}
public CommentType Type {get; set;}
public List<Comment> Comments {get; set;}
public int? ArticleId {get; set;}
public Article? Artcile {get; set;}
public int? CommentId {get; set;}
public Comment? Comment{get; set;}
}
public enum CommentType
{
CommentForArticle,
CommentForComment
}