Accepted answer

as said in the comment you need the include method:

salesorderheaders.include(s => s.salesorderdetails
                                .select(d => d.specialofferproduct))
                 .where(s => s.salesorderid == 43659)

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).

Related Query

More Query from same tag