/// <summary> /// Main entry point of the application. /// </summary> /// <param name="args">List of arguments.</param> static void Main(string[] args) { var root = areaServices.GetAllAreas().Where(a => a.ParentId == null).FirstOrDefault(); areaServices.CreateArea(new Business.Domain.Entities.Area() { Label = "Area 1.1", ParentId = root.Id }); areaServices.CreateArea(new Business.Domain.Entities.Area() { Label = "Area 1.2", ParentId = root.Id }); areaServices.CreateArea(new Business.Domain.Entities.Area() { Label = "Area 1.3", ParentId = root.Id }); List <Area> result = new List <Area>(); var all = areaServices.GetAllAreas().Where(a => a.ParentId == null).ToList(); all.Flatten(a => a.Children, ref result); result.ToList(); }