score:1

Accepted answer

Tim Scmelter's suggested code pretty much did the trick. I had to make one small change to make my record IDs unique and it was good-to-go.

Dim dict = (From op In pOperations _
            From rec In op.Records _
            Group rec By op.Name Into NameGrp = Group) _
           .ToDictionary(Function(grp) (grp.Name), _
                         Function(grp) (grp.NameGrp.Select(Function(r) _ 
                                                           (r.ID)).Distinct().ToList))

score:2

This creates a Dictionary(Of String, List(Of Int32)) with the unique names as key and it's associated Record-ID's as values.

Dim dict = (From op In pOperations
            From rec In op.Records
            Group rec By op.Name Into NameGrp = Group) _
           .ToDictionary(Function(grp) (grp.Name),
                         Function(grp) (grp.NameGrp.Select(Function(r) (r.ID)).ToList))

Related Articles