title: C# + LINQ - inner join
body: <pre><code>Table: one
  Column (PK): employee_ssn
  Column: employee_active bit
  
  Table: two
  Column (pk): date
  Column (FK): employee_ssn
  Column: total_income
  Column: total_expenses
  </code></pre>
  
  <p>Working Linq code to sum total_income and total_expenses for the year, per employee:</p>
  
  <pre><code>var SumOfSections = db.two
                  .Select(x =&gt; x)
                  .Where(x =&gt; x.employee_ssn.Equals(xxxxxxxxx))
                  .Where(x =&gt; x.Date.Year.Equals(year))
                  .GroupBy(x =&gt; x.Date)
                  .Select(g =&gt; new
                  {
                      Total_Income = g.Sum(x =&gt; x.total_expenses),
                      Total_Expenses= g.Sum(x =&gt; x.total_income)
                  })
                  .ToArray();
  </code></pre>
  
  <p>I need to incorporate INNER JOIN to the above to only include active employees.  Working SQL:</p>
  
  <pre><code>select two.total_income,total_expenses
  from two
      INNER JOIN one  
          ON one.SSN = two.SSN
          WHERE one.Active = 1 AND two.Date='1/1/2014' AND two.SSN='xxxxxxxxx';
  </code></pre>
  
  <p>How can I modify my linq code to what my sql code is doing?</p>