public IEnumerable <Area> GetAll() { List <Area> formattedAreas = new List <Area>(); List <Area> areasInDB = (List <Area>)areaRepository.GetAll(); foreach (Area area in areasInDB) { List <Topic> areaTopics = topicRepository.GetAllByCondition(t => t.Area.Name == area.Name).ToList(); area.Topics = areaTopics; foreach (Topic topic in area.Topics) { List <Type> typesInTopic = typeRepository.GetAllByCondition(t => t.IsActive && t.Topic.Name == topic.Name && t.Topic.Area.Name == topic.Area.Name).ToList(); topic.Types = typesInTopic; foreach (Type type in topic.Types) { List <AdditionalField> additionalsInType = additionalfieldRepository.GetAllByCondition( a => a.Type.Name == type.Name && a.Type.Topic.Name == type.Topic.Name && a.Type.Topic.Area.Name == type.Topic.Area.Name).ToList(); type.AdditionalFields = additionalsInType; foreach (AdditionalField additional in type.AdditionalFields) { List <AFRangeItem> rangeValues = rangeRepository.GetAllByCondition( r => r.AdditionalField.Id == additional.Id).ToList(); additional.Range = rangeValues; } } } formattedAreas.Add(area); } return(formattedAreas); }