Skip to content

Commit

Permalink
use where
Browse files Browse the repository at this point in the history
  • Loading branch information
bjosttveit committed Sep 6, 2023
1 parent 4940698 commit bc4594d
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/Altinn.App.Core/Models/Layout/Components/GridComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,12 @@ public class GridCell
/// <inheritdoc/>
public List<String> Children()
{
List<String> gridChildren = new List<String>();

if (this.Rows is null)
{
return gridChildren;
}

foreach (var row in this.Rows)
{
if (row.Cells is null)
{
continue;
}

foreach (var cell in row.Cells)
{
if (cell.ComponentId is not null)
{
gridChildren.Add(cell.ComponentId);
}
}
}
return gridChildren;
return this.Rows?
.Where(r => r.Cells is not null)
.SelectMany(r => r.Cells!)
.Where(c => c.ComponentId is not null)
.Select(c => c.ComponentId!)
.ToList()
?? new List<String>();
}
}

0 comments on commit bc4594d

Please sign in to comment.