score:1
Accepted answer
the linq equivalent would be:
var resultset = cafedras[id - 1].specializations
.select(s => specializations[s - 1])
.selectmany(s => s.displinsid);
foreach(var d in resultset)
console.writeline(disciplinas[convert.toint32(d) - 1].name);
score:2
converting nested loops does not require a join - you can do a sequence of select
calls instead:
var res = cafedras[id - 1]
.specializations
.select(s => specializations[s - 1])
.selectmany(s => disciplinas[convert.toint32(s.displinsid) - 1].name)
.tolist();
above,
- first
select
represents the first loop that createsspecs
- second
selectmany
represents the two nested loops.
this produces list<string>
in the res
, with subject names that could be printed.
Source: stackoverflow.com
Related Query
- Linq join with array
- Linq Query multiples tables join with array of varying table names
- Linq statement instead of SQL with join and array
- Join an array of string with the result of an existing linq statement
- LINQ to SQL - Left Outer Join with multiple join conditions
- How do you perform a CROSS JOIN with LINQ to SQL?
- LINQ Join with Multiple Conditions in On Clause
- Why is LINQ JOIN so much faster than linking with WHERE?
- Convert SQL to Linq left join with null
- LINQ Join with Multiple From Clauses
- Linq query with Array in where clause?
- How do I most elegantly express left join with aggregate SQL as LINQ query
- Linq - Left outer join with dot notation
- Is an outer join possible with Linq to Entity Framework
- Linq join with COUNT
- Linq Join With Include Statement
- linq how to select a parent with a child collection that contains one or many of an array (or list) of values
- Linq to Entity Join table with multiple OR conditions
- Left join on two Lists and maintain one property from the right with Linq
- Select Distinct List of Words from Array with LINQ
- LINQ Join with multiple AND conditions
- How to join 3 tables with linq
- Using LINQ to search a byte array for all subarrays that start/stop with certain byte
- Array operations with n-dimensional array using LINQ (C#)
- JSON.NET Selecting items in array with linq
- How to left join multiple tables with LINQ
- Join tables in SQLite.Net with LINQ on xamarin.android is not supported
- LINQ table join with entity Framework
- When to prefer joins expressed with SelectMany() over joins expressed with the join keyword in Linq
- Where in Query with Array in LINQ
More Query from same tag
- Entity Framework / LINQ - Date From / Date To Comparison
- Linq query for count outside join
- LINQ Query - Group multiple entities and sum
- How to left join two Datables?
- if else condition in LINQ
- Parallel search in 2 collection
- Query to determine whether more than one element has the same value for a property?
- how to limit GET api call based on user properties
- Using Linq comparision with previous record
- How to extract the names of all bookmarks in a Word Xml Document
- Linq query works with null but not int? in where clause
- grouping string with linq to xml
- Error When Adding Creating List From View
- Join tables with linq
- Scala shortest equivalent to c# LINQ
- Retrieving data using LINQ
- How to get a Key of Func<Q, string> based on String Key
- Concatenate string in GroupBy
- Get records from a collection based on a list of integer ids
- How to get LINQ to Autoformat in Visual Studio appropriately?
- Handling null returns in new linq objects c#
- The LINQ expression contains references to queries that are associated with different contexts
- Insert Unicode string to DB using Linq
- Unit Test Linq XML Function
- use a combobox selection for linq query
- Reading either byte[] or float with Linq to Entities
- Converting nodes with the same name to text with c#
- LINQ statement - WHERE clause for ENUM type
- Linq Join and GroupBy refactor
- Linq: Getting missing records