score:2

Here is an aproximation with a recursive solution:

In your view:

@WriteChilds(null, "")

And this the method body, I'm sure you can translate Console.WriteLine to html output:

public void WriteChilds(int? ParentCategoryId, string parentName) {
    var categories = Model.Where(a => a.parentCategoryId == ParentCategoryId);
    foreach(var category in categories) {
        Console.WriteLine(parentName + " " + category.CategoryName);
        WriteChilds(category.CategoryId, category.CategoryName);
    }
}

Related Query

More Query from same tag