title: Left/Right/Inner joins using C# and LINQ
body: <p>I am trying to figure out how to do a series of queries to get the updates, deletes and inserts segregated into their own calls.  I have 2 tables, one in each of 2 databases.  One is a Read Only feeds database and the other is the T-SQL R/W Production source.  There are a few <strong>key</strong> columns in common between the two.</p>
  
  <p>What I am doing to setup is this:</p>
  
  <pre><code>List&lt;model.AutoWithImage&gt; feedProductList = _dbFeed.AutoWithImage.Where(a =&gt; a.ClientID == ClientID).ToList();
  List&lt;model.vwCompanyDetails&gt; companyDetailList = _dbRiv.vwCompanyDetails.Where(a =&gt; a.ClientID == ClientID).ToList();
  foreach (model.vwCompanyDetails companyDetail in companyDetailList)
  {
      List&lt;model.Product&gt; productList = _dbRiv.Product.Include("Company").Where(a =&gt; a.Company.CompanyId == companyDetail.CompanyId).ToList();
  }
  </code></pre>
  
  <p>Now that I have a (source) list of products from the feed, and an existing (target) list of products from my prod DB I'd like to do 3 things:</p>
  
  <ol>
  <li>Find all SKUs in the feed that are not in the target</li>
  <li>Find all SKUs that are in both, that are active feed products and update the target</li>
  <li>Find all SKUs that are in both, that are <strong>inactive</strong> and soft delete from the target</li>
  </ol>
  
  <p>What are the best practices for doing this without running a double loop?  Would prefer a LINQ 4 Objects solution as I already have my objects.</p>
  
  <p>EDIT:  BTW, I will need to transfer info from feed rows to target rows in the first 2 instances, just set a flag in the last instance.</p>
  
  <p>TIA</p>