title: How to translate t-sql sum() to linq sum()
body: <p>I have something like this: </p>
  
  <p><a href="https://i.stack.imgur.com/IGJaV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IGJaV.png" alt="SQL query"></a></p>
  
  <p>And I need to re-write this query into LINQ. </p>
  
  <p>I tried:</p>
  
  <pre><code>var EachProduct = (from b in _context.ReleasePlans
                                      join a in _context.Products
                                          on b.ProductProductId equals a.ProductId
                                      where b.DepartmentDepartmentId == departmentId
                                       select new { ProductId = b, ProductName = a });
  </code></pre>
  
  <p>But how can I do SUM() and DATEPART() function in Linq?</p>
  
  <p><strong>UPD:</strong> Query using lambda expression. But the question remains the same</p>
  
  <pre><code>var EachProduct = _context.ReleasePlans
              .Where(b =&gt; b.DepartmentDepartmentId == departmentId)
              .Join(_context.Products, a =&gt; a.ProductProductId, b =&gt; b.ProductId,
                  (b, a) =&gt; new {ProductId = b, ProductName = a});
  </code></pre>