score:2
as said in the comment you need the include
method:
salesorderheaders.include(s => s.salesorderdetails
.select(d => d.specialofferproduct))
.where(s => s.salesorderid == 43659)
.single().salesorderdetails
this will join the required data (in sql) and populate the navigation properties.
note, however, that you can't use syntax like
.include(s => s.salesorderdetails.where(sod => sod.orderqty > 3)
.select(d => d.specialofferproduct))
which seemingly would partly populate salesorderdetails
. there are change requests to the ef team to implement this, but so far, this hasn't been done.
another side note is that it's useless to return specialproducts
as iqueryable
because subsequent queries on the collection won't get translated to sql anyway. you can only access the property in in-memory statements in the first place, not in linq-to-enitites queries (ef cant translate the property into sql).
Source: stackoverflow.com
Related Query
- LINQ Query Using Navigation Properties Generates Multiple SELECT Statements
- ASP.NET : select multiple values in query using Linq
- Using navigation properties in LINQ query causes problems such as relationship multiplicity
- select multiple objects using one linq query in entity framwork 6
- Efficient Hierarchal Linq query using multiple properties
- Linq Query using navigation properties and Where clause
- LINQ query nested loop with multiple select statements
- LINQ-to-SQL: Select mulitple properties from top row of each GROUP using LINQ query
- Using linq to select possible values for multiple database columns in one SQL query (EF6)
- Using navigation properties in linq query throws error if foreign keys are null
- Select from Multiple List inside cascading DropDownList using condition in Linq query c#
- How to select from multiple tables using LINQ using a union query to return only one column?
- select single or multiple records using a single linq query
- Can I select multiple objects in a Linq query
- How to select multiple values from a Dictionary using Linq as simple as possible
- Using LINQ to find duplicates across multiple properties
- Using LINQ to group by multiple properties and sum
- Using Linq to Select properties of class to return IEnumerable<T>
- Deleting multiple records with Entity Framework using a single LINQ query
- Select Multiple elements in a row using Linq
- LINQ Query - How to map a resultset into another object using Select
- Linq query with multiple OrderBy statements added in a loop
- How to reuse a linq expression for 'Where' when using multiple source tables
- Linq Query to Group By Multiple Columns But Get Additional Properties
- How to Query from Asp.Net Profile Properties using LINQ
- Select method is not called using LinQ query syntax
- Using async/await inside a Select linq query
- How can I write the following code more elegantly using LINQ query syntax?
- Problems trying to use GroupBy with multiple properties using the LINQ Method Syntax
- Linq query to select single string from multiple List<string>
More Query from same tag
- c# WPF bind combobox to TPH in Entity Framework code first using LINQ
- SQLite bitwise query to EF Core Linq version?
- Least code to convert one object to anothe for both single object and List<object>?
- Check if string already exist in Table
- Count items existing in 2 Lists
- ASP.NET MVC - Join Tables using LINQ
- Creating a string from a lambda expression
- LINQ Join On Int = Char DataTypes?
- Linq build query dynamically with no concrete Type
- How can I use LIKE operator instead of IN operator for multiple commas contains string in stored procedure
- 'Where' statement in LinQ to Sql
- How to invoke the static constructors in LINQ and sort elements by a static property?
- c# search over multiple columns
- Looking to get information from two different tiers of nested lists
- How to move record from one server to another server in a efficient way on daily basis?
- I have a custom expression program with a lexer, parser and evaluator. How do I LINQ-ify it?
- Linq to SQL how to do “where [column] in (list of values)”
- Lambda or LINQ for Complex Filter?
- Is this the best way to create a frequency table using LINQ?
- Based on date, get todays and the next two days values from XML?
- Cannot access or find reference to System.Xml.Linq.LineInfoAnnotation. Why is this?
- Translating GROUP BY / MIN DATE from SQL to LINQ
- Compare efficiency of two different LINQ statements
- how to get value of a definite Column name in c# / Linq?
- Entity framework. How to right map tables without primary key
- how to find average of each column of a datatable using c#
- Database is locked when inside a foreach with linq without ToList()
- Convert OR to And Condition on array values in LINQ c#
- What are the names given to these 2 LINQ expressions
- Select all rows from a model and have a nested json element as the Foreign key to another model with all rows selected