I have a table which I have column:
Id Name Description ParentId CreationDate ModificationDate
enter image description here
Currently I am getting data as below:
[
"cat1",
" subcat1",
" subsssubcat1",
"cat2",
"cat3"
]
public IEnumerable<string> FormatTree(ILookup<int?, NestedCategory> lookup, int? parent, int indent)
{
return
from c in lookup[parent]
from t in new[] { parent.ToString().PadLeft(indent * 4) + c.Name }.Concat(FormatTree(lookup, c.Id, indent + 1))
// from t in new[] { parent==0? ("Category:".PadLeft(indent * 4) + c.Name):("SubCategory".PadLeft(indent * 4) + c.Name ) }.Concat(FormatTree(lookup, c.Id, indent + 1))
select t;
}
IEnumerable<string> INestedCategoryRepo.GetAllNestedCategories()
{
var lookup = _context.NestedCategories.ToLookup(x => x.ParentID);
return FormatTree(lookup, 0,0);
}
But it is not differentiating category subcategory.
I want identifier so that it can easily identify.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…