I have the following List which contains the following collection.
How i can transform this with linq so that i get nested items.
var categories = new List<Category>(); // id, parentId, name
categories.Add(1, 0, "Sport");
categories.Add(2, 0, "Pets");
categories.Add(3, 1, "Foot ball");
categories.Add(4, 2, "Cat");
categories.Add(5, 3, "Pele");
categories.Add(6, 4, "whiskers");
// ie Pets - > Cat - > Whiskers
public class Category
{
public int Id { get; set; }
public int ParentId { get; set; }
public ICollection<Category> Categories { get; set; }
}