❔ How to make categories correctly?
I need to make a category in such a way that each can be inherited. I have this model:
Unfortunately, I'm having a big problem making an efficient query in EF Core. Did I do the model right?
public class Category
{
public int Id { get; set; }
public Thread Thread { get; set; } = null!;
public Guid ThreadId { get; set; }
public int Sorting { get; set; } = 0;
public string Name { get; set; } = string.Empty;
public ICollection<CategoryDetail> Details { get; set; } = null!;
public ICollection<Category> Subcategories { get; set; } = new List<Category>();
public int? CategoryId { get; set; }
}public class Category
{
public int Id { get; set; }
public Thread Thread { get; set; } = null!;
public Guid ThreadId { get; set; }
public int Sorting { get; set; } = 0;
public string Name { get; set; } = string.Empty;
public ICollection<CategoryDetail> Details { get; set; } = null!;
public ICollection<Category> Subcategories { get; set; } = new List<Category>();
public int? CategoryId { get; set; }
}public class CategoryDetail
{
public int Id { get; set; }
public Category Category { get; set; } = null!;
public int CategoryId { get; set; }
public string Culture { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}public class CategoryDetail
{
public int Id { get; set; }
public Category Category { get; set; } = null!;
public int CategoryId { get; set; }
public string Culture { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}Unfortunately, I'm having a big problem making an efficient query in EF Core. Did I do the model right?