score:1
Accepted answer
Basically you have two options.
- Read both tables into memory and process the result in code. Suitable for small collections.
- Create a view with a recursive CTE and map that view in EF. Join with that view. More complicated to write, but gives the best performance, especially for large collections.
Source: stackoverflow.com
Related Articles
- LINQ query for an aggregate count with a recursive relationship
- how to write a Linq query with a EF code first Many to Many relationship
- How do I most elegantly express left join with aggregate SQL as LINQ query
- Simple sql to Linq query with group by and aggregate functions
- Translating query with GROUP BY and COUNT to Linq
- LINQ to SQL: Complicated query with aggregate data for a report from multiple tables for an ordering system
- Write a comparable LINQ query for aggregate distinct count in sql?
- Optimize/rewrite LINQ query with GROUP BY and COUNT
- Linq query with OrderBy word count
- How to query many-to-many relationship with 'AND' condition using LINQ and Entity Framework
- Linq query with multiple count
- CTE recursive query with linq mvc
- Using Linq to return the count of items from a query along with its resultset
- Fast linq query with join and count
- query and create objects with a one to many relationship using LINQ
- Linq sub query when using a repository pattern with EF code first
- Linq query with GROUP BY on multiple fields, SUM and COUNT
- Self join with aggregate query in LINQ
- Linq query with count (extension method)
- Linq to sql query with Parent child relationship
- LINQ Aggregate results with Many to Many Relationship
- Usage recursive hierarchy tree structure in Linq query with multible tables and return some Json Value
- How to convert an MySql query to Linq with count and attributes
- how to make 1:many relationship between models with different query ( linq syntax )
- Aggregate using LINQ with Query Expression syntax
- Linq query with multiple objects in parent child relationship
- Avoiding repeating code with Linq query + optional params
- LINQ query with distinct count
- How to write a count and group by month query with linq
- Count nulls in properties with one LINQ query
- Linq entity using where clause twice in a row
- LINQ pass in value for each iteration
- Why does my Linq query throw an exception when I try and sort on DateTime?
- Converting SQL query result to Linq result with an new field that is not in the Model
- The type arguments cannot be inferred from the query in linq c# query
- LINQ to XML - Get element based on a nested elements value
- Displaying results from LINQ query in ASP.NET MVC
- Switch DbFunctions to a non-db implementation depending on context
- Sorting XML with Alphabetic and numeric (code="BC1")Attribute in C#
- NullReferenceException using where clause
- How to call List in LINQ?
- Viewmodel not working correctly MVC error
- Asp.Net Identity find users not in role
- Is there a way to increase performance on these two foreach loops?
- LINQ: grouping collection
- Remove an item from a LINQ collection
- Fill List<ViewModel> with strings from Regex.Matches
- Getting Row Index for LINQ Query using Custom Object
- Entity Framework Include in Where Subquery
- IF statement inside a LINQ SELECT to include columns