title: c# lambda expression using Sum for multiple comparisons
body: <p>I'm trying use the Sum method in a lambda expression for a comparison, but I want to use it for multiple comparisons.  How do I accomplish this?  I've looked at "Let" and "SelectMany", but I haven't been able to find an answer.</p>
  
  <p>Below is what the code looks like:</p>
  
  <pre><code>return _dbContext.All&lt;Table&gt;()
              .Where(table =&gt; table.CurrentLevel &lt;= salesCriteria.MaxTableLevel)
              .Where(table =&gt;  table.Leg
                              .Where(leg=&gt; salesCriteria.StartDate &lt;= leg.AddDate)
                              .Where(leg=&gt; leg.AddDate &lt;= salesCriteria.EndDate)
                              .Sum(leg =&gt; leg.Width) &lt;= salesCriteria.MaxGoalAmount);
  </code></pre>
  
  <p>As you can see, I'm trying to get all Tables with certain criteria that have Legs with certain criteria and whose width all add up to be less than a certain value.  I would also like to make sure that the Sum is greater than a certain min value.  However, I can't do that here since as soon as I do .Sum, I lose the list.  So how would I accomplish that here?  All I want is  minValue &lt;= .Sum() &lt;= maxValue</p>