score:1
try it like this. you might need to change some of the "select" and "selectmany" options and the id field names as you did not post the context.`
var query = _context.equipment.include(x => x.group)
.include(x => x.status)
.include(x => x.area)
.include(x => x.equipmenttype)
.include(x => x.notes)
.include(x => x.department)
.include(x => x.pmaintenance)
.include(x => x.maintenancehours)
.include(x => x.attachments)
.include(x => x.request).firstordefault(x => x.equipmentid == id);
query.include(x => x.parts).theninclude(x => x.childrenparts).selectmany(x => x.parts).where(a => query.select(q => q.partsid).contains(a.id)).load();
query.selectmany(x => x.parts).selectmany(x => x.childrenparts).load();
query.selectmany(x => x.parts).selectmany(x => x.parentparts).load();
query.selectmany(x => x.parts).select(x => x.vendor).load();
query.include(x => x.systeminfo).theninclude(x => x.systemusers).selectmany(x => x.systeminfo).where(a => query.select(q => q.systeminfoid).contains(a.id)).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.frameworks).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.videocards).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.storagedrives).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.software).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.networkadapters).load();
query.selectmany(x => x.systeminfo).selectmany(x => x.printers).load();
query.tolist();
hope this helps.
Source: stackoverflow.com
Related Query
- EF Core 3.0 .Include() chain taking ~5-10x longer than 2.2
- Include / ThenInclude with where in EF Core
- .NET CORE 2 EF Include
- Net core EF 3.1 LINQ string comparison no longer working
- EF Core Include On Collection Class Property
- Entity Framework Core : LINQ advise needed on better approach using include for relational tables
- LINQ Source Code Available
- Linq To Sql surprisingly fast retreving data. Is it normal that it is 10x faster than ADO?
- Stored procedure called from C# executes 6 times longer than from SQL Management studio
- .NET 4 Code Contracts: "requires unproven: source != null"
- Why is Entity Framework core loading entity's relations without adding include
- EF Core Include method not working
- creating Linq to sqlite dbml from DbLinq source code
- EF Core Queryable<T>. Count() returns different number than Queryable<T> .ToList().Count(). Is this even possible or is it a bug?
- EF Core "InvalidOperationException: Include has been used on non entity queryable" for navigation property even after explicit include
- EF Core “InvalidOperationException: Include has been used on non entity queryable” on IQueryable
- Include vs. ThenInclude for grandchild properties in EF Core
- Why can I not do more than one level of include in my LINQ statement?
- ef core 5.0 How to Filtered Include
- Nested include Entity Framework Core
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Entity Framework code first - Many to Many - Include conditional
- LINQ include "&&" operator if value is greater than zero
- Extension of IEnumerable's Select to include the source in the selector
- source code for LINQ 101 samples
- EF Core conditional include
- EF Core 3.x - simple LINQ with Include can not be translated, client evaluation
- Exclude deleted child when using EF core Include
- Filtering on Include reverted if I perform Select afterwards in EF Core
- EF Core does not include all the child items
More Query from same tag
- Build dynamic linq select query from existing list
- Why stored procedure result is zero?
- Linq query is super slow?
- Linq - get top 2 records through criteria
- How to use transactions with a datacontext
- How to sort list of objects with field containing both words and numbers?
- Wrong order when using System.Linq.Dynamic with MongoDB collection
- How to implement pivot data in Entity Framework?
- How to filter child collections in Linq
- What is more efficient with Joins and multiple selects working with LINQ?
- How do I find all parent objects that do not have child object with specific property?
- Join and get Distinct on Foreign Objects/Keys Linq
- PartialView passing Customized List using LINQ
- Linq query error
- C# How to change Xml node values using Linq
- How can I use an alias for column name in linq method-based query?
- Can I merge two lists using Linq?
- LINQ operators versus LINQ methods: limitations, pros / cons of one over the other?
- VB.net Add new listview item in listview with Checked True?
- Querying container with Linq + group by?
- Natural join in .net
- C# Linq - Delayed Execution
- Adapt navigational property using Mapster
- Find distinct values from a list of object by one field only
- Merging Two List with Same Properties into One List
- Linq DataTable and Take Method
- Get array index values of the top 1000 largest entries inside an array using LINQ
- Convert SQL Query to Linq (contains left joins)
- how do I combine Expression<Func<MyClass,bool>>[]?
- Is it bad practice to purposely rely on Linq Side Effects?