I have a single table which expresses a possible parent child relationship between Categories. Root categories would not contain a ParentId value, rather null. I think it's also important to point out that it should construct N level of depth.
For example consider the following Sql table.
Category : Id | Name | ParentId
Where ParentId is a relationship back to the Id column of the same table.
Trying to understand if it would be possible to populate the following class?
public class Category
{
public string Id
{
get;
set;
}
public string Name
{
get;
set;
}
public List<Category> Categories
{
get;
set;
}
}
from a method such as :
public List<Category> GetCategories()
{
// construct using dapper.
}