score:2
Accepted answer
You must use SelectMany
.
If you use Select
, then you get a Enumerable<List<Node>>
, with SelectMany
, you get only a List<Node>
List<Node> exitNodes = gateways.SelectMany(gw => gw.Connections).Select(node => node).ToList();
The answer in this post explains the difference between SelectMany
and Select
:
https://stackoverflow.com/a/959057/5056173
Source: stackoverflow.com
Related Query
- LINQ merging multiple lists
- Merge multiple Lists into one List with LINQ
- Remove duplicates while merging lists using Union in LINQ
- Does this LINQ code perform multiple lookups on the original data?
- Linq get values not shared across multiple lists
- Interleaving multiple (more than 2) irregular lists using LINQ
- Merging 2 lists and sum several properties using LINQ
- Merging 2 Lists in LINQ
- Linq - merging sub lists from different objects into a single object
- How to reuse a linq expression for 'Where' when using multiple source tables
- LINQ to SQL, How to merge multiple IQueryable Lists of different subtype?
- LINQ Source Code Available
- multiple orderby in this linq code
- Efficient method of merging multiple lists based on item weights
- Merging few lists into one using linq
- Merging multiple lists
- creating Linq to sqlite dbml from DbLinq source code
- LINQ Query to Filter Items By Criteria From Multiple Lists
- LINQ How to return common objects across multiple lists
- How to combine multiple lists using LINQ lambda
- Find common items in multiple lists in C# linq
- LINQ - joining multiple lists
- LINQ - Combine multiple lists to form a new list and align them by key?
- Merging 2 lists with linq based on unique Id to avoid duplicates
- Error in merging 2 LINQ lists
- How to assign multiple LINQ Include() statements to a variable for code re-use?
- Joining & Transposing multiple Lists using LINQ
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- Optimizing LINQ combining multiple lists into new generic list
- Linq query that tests for existence in multiple lists
More Query from same tag
- Using DefaultIfEmpty with an object?
- Call LINQ Query within If Condition in C#/WPF
- ForEach loop with Lambda expression in Razor code MVC 5 For List<T>
- Linq expression meaning
- Entity framework loads all records for large table when only a subset is required
- How to change all values in a Dictionary<string, bool>?
- Null checking inside where clause in Entity Framework Linq
- EF Core does not include all the child items
- How to Connect to SQL Server using LINQ to SQL?
- Linq code to get the index of an object in an array from an object within a list
- How to check value of item is not equal to zero before adding in a list?
- Getting Stack Overflow when performing Linq to Sitecore Query
- Reordering the linq statement after group by
- Convert linq result to name value pair
- how to sort a List based on the form order in another List
- LINQ - How to Flatten List<List<string>> where strings are pipe-delimited
- SQL generated by LINQ for logging
- LINQ and the KeyValuePairs
- Basic array Any() vs Length
- select xml mode in Linq retrieve duplicate results
- Can I pass a 'using' context to another method in c#?
- Nullable Expressions
- How to sort class list by integer property?
- How to get data from two tables but with where clause on the second (FOREIGN KEY) table? [LINQ]
- Linq syntax for encapsulated value in array
- LINQ query to get records for the last 30 days
- If person with specific name exists in People XML list
- Return Count from Netflix oData Service When the LINQ Count() Method Doesn't Work
- In linq to EF can I create a dynamic query to search on a field specified by the user
- vb.net datatable asenumerble get distinct vlues and count grouped duplicate rows