using System.Collections.Generic;
public static void Main()
List<Employee> employees = new List<Employee>
new Employee { Name = "foo", Type = "A" },
new Employee { Name = "bar", Type = "B" },
List<Employee> employees2 = new List<Employee>
new Employee { Name = "abc", Type = "X" },
new Employee { Name = "xyz", Type = "A" },
new Employee { Name = "jkl", Type = "A" },
List<Dept> depts = new List<Dept>
new Dept { Name = "Sales", Category = "Finance", Employees = employees },
new Dept { Name = "Physics", Category = "Science", Employees = employees2 },
new Dept { Name = "HR", Category = "HR", Employees = employees2 },
var result = depts.SelectMany(x => x.Employees.Where(z => z.Type == "A"), (DeptObj, empObj) =>
).GroupBy(x => x.Category)
.Select(x => new NewModel { Category = x.Key, EmpNames = x.Select(z => z.empObj.Name).ToList() });
foreach(var item in result)
Console.WriteLine("Category: {0}", item.Category);
foreach(var name in item.EmpNames)
Console.WriteLine("\t{0}", name);
public string Name { get; set; }
public string Type { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public List<Employee> Employees { get; set; }
public string Category { get; set; }
public List<string> EmpNames { get; set; }