private static IEnumerable<CategoryDto> GetChildren(string parentId, CategoryDataRow[] categoryRows) { return categoryRows .Where(c => c.ParentId == parentId) .Select(c => new CategoryDto(c.Id, c.Title, GetChildren(c.Id, categoryRows).ToArray())); }
private static CategoryDto BuildHierarchy(CategoryDataRow[] categoryRows) { return new CategoryDto(null, null, GetChildren(null, categoryRows).ToArray()); }