score:0
Change your loModel to join all three tables. Then, you will need one foreach
only.
score:0
Try something like this:
from client_uo in UserObjects
join client_obj in Objects on client_uo.ObjectID == client_obj.ObjectID
join p in Problems on p.ObjectID == clt_obj.ObjectID
join pu in ProblemUsers on p.ProblemID == pu.ProblemID
join assignee in Users on pu.UserID == assignee.UserID
where client_obj.UserID == ClientUserID
that should produce a multi join that gets you from ClientUserID to Client-UserObjects to ProblemObjects to Problems to ProblemUsers (assignees?) to Users, with all the data available at one go. You may want to group it together, either by object, by problem, or by assigned user, depending on the display you're trying to produce.
Source: stackoverflow.com
Related Articles
- EF code first make one to many relationship
- Entity-framework code is slow when using Include() many times
- Does adding .ToArray or .ToList always make database queries faster?
- How can I make sure my LINQ queries execute when called in my DAL, not in a delayed fashion?
- List queries 20 times faster than IQueryable?
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- How can I make my Many-to-Many queries faster?
- many to many mapping in entity framework code first
- creating Linq to sqlite dbml from DbLinq source code
- How do I make LINQ queries to an SQLite database?
- Does LINQ convert code to SQL queries
- SelectMany makes too many queries
- composing many quotations into linq queries
- Is there any way to make Code Contracts work with LINQ?
- Lambda Expression for Many to Many realtionship in C# EF 5 Code First
- Using Linq to build a graph class; can you make this code look better?
- Does a code that combines single() with yield make any sense?
- Entity Framework code first - Many to Many - Include conditional
- Can I make this two LINQ queries into one query only?
- EF Core - many queries sent to database for subquery
- How to make EF query who return aggregated values for many to many relation tables in MVC 5 ASP.NET
- Make access possible to dynamic table LINQ EF6 Code First
- System.Linq.Dynamic.Core : How do I make a select many correctly?
- EF Code First Insert Objects with One to Many gives exception."Store update, insert, or delete statement affected an unexpected number of rows (0)."
- Do LINQ queries make use of the underyling data type?
- Convert/Parse many Objects using a member Method with less Code
- How to make a property unique in Entity Framework Code First
- source code for LINQ 101 samples
- Help me make this LINQ query faster please?
- How to validate null values on linq
- Data binding performance in ASP.Net web forms controls of entire class vs selection of property. Good practice?
- retrieve model properties values inside GET method in mvc
- Fillter and copy XML nodes using Linq to XML
- Is it possible to change & to & in the results from a LINQ query?
- cannot convert from 'System.Collections.Generic.List<NS.TagCollection>' to 'NS.TagCollection'
- Nested transactions in LINQ to SQL
- Hide or remove a spinner Xamarin.Android
- Display data in hierarchical order using LINQ
- Using .Contains within a linq query returning a SystemException
- Anonymous Methods / Lambda's (Coding Standards)
- How do you Left join 'Is Not Null' using linq?
- LINQ NHibernate, latest related entity
- LINQ to Entities: Age calculation in a LINQ query causes "Method cannot be translated into a store expression"
- Operator '>' cannot be applied to operands of type 'string' and 'string' in query
- Using Linq to get groups from a collection
- How to return only rows where no rows from another table using Lambda Expressions in C#
- Cannot Implicitly convert type IQueryable to IOrderedQueryable
- Get me the other items also bought with particular product, in LINQ?
- Sorting objects by similarity with linq