I have the following Table Structure
Orders
OrderID PK
PartyAddresses
PartyAddressID PK
Then I have a join table that joins PartyAddress to a order
OrderAddresses
OrderAddressID PK
OrderID FK to Orders
PartyAddressID FK to PartyAddresses
AddressType
The sql statment I am trying to convert is
SELECT
*
FROM
Orders o LEFT JOIN OrdersAddresses oa
ON
o.OrderID = oa.OrderID
LEFT JOIN PartyAddresses pa
ON
pa.PartyAddressID = oa.PartyAddressID
WHERE
oa.AddressType = 'SHIP'
I am having trouble figuring out to replicate this into Linq lambda statements
I have been been able to retrieve the data I want by starting at the OrdersAddress table
OrdersAddresses.Include("Orders").Include("PartyAddresses").Where(oa=>oa.AddressType=="Ship");
But I need the results in terms of a IEnumerable<Orders>
Update
I guess to rephrase my question - given the following repository function
public IQueryable<Orders> OrdersWithAddresses()
{
return _context.Orders.Include("OrdersAddresses").Include("OrdersAddresses.PartyAddresses");
}
How would i add to the expression tree to only actually return order addresses that are "SHIP"