score:1

the easiest way is probably to "flatten" the problem and then do the group by:

    var query = officers.selectmany(
        x => new[] {
            new { x.name, ro = x.reportingofficer1 },
            new { x.name, ro = x.reportingofficer2 },
            new { x.name, ro = x.reportingofficer3 }
        }
    );
    var grouped = query.groupby(y => y.ro);
    foreach (var group in grouped) {
        foreach (var item in group) {
            console.writeline(string.format("{0}: {1}", item.ro, item.name));
        }
    }

here, i am assuming officers is a ienumerable<officer> where

class officer {
    public string name { get; set; }
    public string reportingofficer1 { get; set; }
    public string reportingofficer2 { get; set; }
    public string reportingofficer3 { get; set; }
}

with your sample data this is my output:

john: a
john: b
jack: a
rob: a
rob: c
earl: b
carl: b
carl: d
chris: c
kenny: c
rodney: d
jacob: d

Related Query