© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
Alerin

❔ How to make categories correctly?

I need to make a category in such a way that each can be inherited. I have this model:
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ How to deserialize correctly
C#CC# / help
4y ago
✅ How to use switch correctly?
C#CC# / help
3y ago
❔ How to set a borders correctly ?
C#CC# / help
4y ago
How to make .Epub
C#CC# / help
3y ago