using System.Collections.Generic;
public static void Main()
var source = new List<Controller>() {
Actions = new List<Action> {
Id = 1, IsSelected = true
Id = 2, IsSelected = false
Actions = new List<Action> {
Id = 1, IsSelected = true
Id = 3, IsSelected = false
Id = 4, IsSelected = true
.Where(x => x.Actions != null)
.SelectMany(x => x.Actions.Where(z => z.IsSelected).Select(a => a.Id))
foreach(var result in toAdd) {
Console.WriteLine(result);
public class Controller {
public List<Action> Actions {get; set;}
public int Id {get; set;}
public bool IsSelected {get; set;}