using System.Collections.Generic;
public static void Main()
List<Row> accounts = new List<Row>() {
new Row() { Client = "123", Account = "123.def", Status = "Open" },
new Row() { Client = "456", Account = "456.def", Status = "Closed" },
new Row() { Client = "123", Account = "123.abc", Status = "Open" },
new Row() { Client = "789", Account = "789.abc", Status = "Open" },
new Row() { Client = "456", Account = "456.abc", Status = "Closed" },
new Row() { Client = "789", Account = "789.ghi", Status = "Open" },
new Row() { Client = "789", Account = "789.def", Status = "Closed" },
new Row() { Client = "789", Account = "789.jkl", Status = "Open" },
List<Client> clients = accounts
.Select(y => new Client() {
Accounts = y.GroupBy(z => z.Account)
.Select(z => new Account() {
Number = z.First().Account,
Status = z.First().Status
public string Client { get; set; }
public string Account { get; set; }
public string Status { get; set; }
public string Code { get; set; }
public List<Account> Accounts { get; set; }
public string Number { get; set; }
public string Status { get; set; }