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 Query
- LINQ query for an aggregate count with a recursive relationship
- 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?
- how to write a Linq query with a EF code first Many to Many relationship
- LINQ to Entities query for count and group by with join on 2 tables
- LINQ Intersect Query for Many to Many relationship using .NET4 MVC4 Code First
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- Proper Linq Query for objects with many to many relation ship generated with code first entity framework
- LINQ query with DateTime column, groupby Date only with 2nd variable, count total entries for each subgroup
- How do I most elegantly express left join with aggregate SQL as LINQ query
- Linq query with multiple Contains/Any for RavenDB
- Simple sql to Linq query with group by and aggregate functions
- Translating query with GROUP BY and COUNT to Linq
- Optimize/rewrite LINQ query with GROUP BY and COUNT
- linq - how do you do a query for items in one query source that are not in another one?
- 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
- Determine the source DataContext for a Linq to Sql query
- Is possible to run a query with linq to search for a period of time?
- Query for existence of an object with LINQ (to Entities)
- How to return partial results and the total count for a query with Entity Framework?
- Using Linq to return the count of items from a query along with its resultset
- Stubbing Code for Test With Linq Expressions and Lambdas
- Fast linq query with join and count
- How to do a LINQ query for count of entity whose owner == current user?
- 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 for An object with 2 collections
More Query from same tag
- ERPTable columns being truncated
- How to concatenate all child elements with same names values using LINQ to XML
- how to remove elements from xml by index
- parsing an xmldocument from a webrequest
- Generate checkboxes in or selectable buttons in WPF from database
- Trying to do a sub query in Linq ... having issues!
- How to use Enums with Dynamic Linq?
- Count within a formatted DateTime with LINQ
- How to combine multiple lists using LINQ lambda
- How to cast an IEnumerable<object> to an IEnumerable<runtime type>
- list inside another list select
- How to query data within a session variable using linq
- Using Entity Framework Efficiently
- case when for getting a scalar value using linq to sql
- populate array list from For loop using entire database table row
- Cannot assign void to an implicitly-typed local variable
- Filter Linq EXCEPT on properties
- Linq - Using GroupBy with my own type vs anonymous type
- Data binding or foreach for displaying files from isolated storage
- Visual Studio 2015 missing XML comments / documentation
- want to get data from specific column of azure mobile service table using linq
- PowerShell's equivalent of LINQ All, or how can I verify all the items in the collection are equal to specific value?
- I am working on linq to entity framework and i have issue in getting data in my service
- Why Linq can't translate expression/treat as local expression and throws an exception?
- Linq - Question concerning the 'Any' method
- LINQ to SQL not getting correct data
- Make linq subquery
- Nested LINQ with multiple lists
- removing items from a generic List<t>
- C# Linq - EF, select grouped data having the max value