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))
Source: stackoverflow.com
Related Articles
- How can I use LINQ to filter a collection of nested classes to yield a dictionary of unique properties of those classes?
- How to Filter Nested Collection within Dictionary using LINQ C#
- LINQ filter list by nested collection
- filter elements in nested dictionary LINQ
- Filter a nested collection and return main object using LINQ
- Linq nested collection filter
- How can I filter a nested dictionary using LINQ in C#?
- Generic hierarchy filter of nested classes in Linq
- Filter (Triple) Nested Collection using Linq C#
- c# LINQ filter nested collection
- How can I filter a dictionary using LINQ and return it to a dictionary from the same type
- How to filter nested collection Entity Framework objects?
- LINQ - filter child collection
- C# LINQ - convert nested dictionary to a list
- Select object from nested collection using Linq
- Filter a collection with LINQ vs CollectionView
- LINQ WHERE method alters source collection
- Need a linq to objects query for a nested collection
- LINQ - filter collection inside collection
- LINQ Source Code Available
- Use linq expression to filter a dictionary with a list of keys
- Filtering a nested collection using linq
- LINQ Sum Nested collection with GroupBy and OrderByDescending
- Use LINQ to query nested OData collection
- Using Linq to filter out certain Keys from a Dictionary and return a new dictionary
- How to use LINQ to filter property of child collection using (.Any())
- Merging two classes into a Dictionary using LINQ
- How to add TimeSpans together using LINQ when in a Dictionary collection
- LINQ querying nested dictionary with multiple key value selection in C#
- Transfor List to Nested Dictionary using linq C#
- linq one to many relationship stores only one member of list
- Add simultaneity two object depend on each other
- sort stackpanel based on child elements?
- How to get the result of a `linq` back to a DataTable?
- c# get new list of elements grouped between certain element in list
- Solid way to filter lists with different values and list sizes
- Binding LINQ query to DataGridView
- How to populate DataTable with anonymous LINQ result
- How to get first record in each group using Linq
- Setting anonymous type property name
- Take all items in sub-categories using LINQ
- Retrieving large amount of records under multiple limitations, without causing an out-of-memory exception
- DayOfWeek in LINQ query
- Does Linq have a startup penalty?
- GroupBy with multiple groups as a hierarchy
- Trying to load multiple XML input files into iDictionary<string,Ojbect>
- Query aggregation with List of Objects
- Resharper: Possible Multiple Enumeration of IEnumerable
- find list of one item not in second list
- C# min from datatable row