linq querying entity framework how to join tables? navigation properties?
<p>Hi there I am stuck on a problem and hope someone can explain the answer to me!</p>

<p>So in my database I have 3 tables that connect like this: </p>

<pre><code>Customer         CustomerAddress        Address
-CustomerID      -CustomerID            -AddressID
-FirstName       -AddressID             -Street
-LastName                               -City
</code></pre>

<p>So I create my entity model and the middle table(CustomerAddress) is removed and replaced by navigation properties?</p>

<p>So what I'm trying to do is join the tables using a LINQ query in C#.
in SQl the query would look something like this:</p>

<pre><code>Select *
From dbo.customer as c
left join dbo.customeraddress as ca on c.customerID = ca.customerID
left Join dbo.Address as a on a.addressID = ca.addressID
</code></pre>

<p>I realise thats not the case here since there is no customeraddress table. Do I use the navigation properties columns to make a join? In my model diagram I notice there is a navigation property called Addresses in the Customer class/table that seems to map to the Address class/table property called Customers.</p>

<p>So I've tried this:</p>

<pre><code>var customerQuery = (from customer in db.Customers
                     join address in db.Addresses on customer.Addresses equals address.Customers into add
                     from rt2 in add.DefaultIfEmpty()
                     select new { //.. });
</code></pre>

<p>But that is obviously incorrect, as I am unsure what to do with the navigation properties to join them. I would really appreciate if anyone could explain to me how I go about joining with this model!</p>