title: Linq Sum with group by
body: <p>I am having a table structure with columns </p>
  
  <p>FeesNormal</p>
  
  <p>FeesCustom</p>
  
  <p>Currency </p>
  
  <p>Now i am looking for a SUM function group by currency . </p>
  
  <p>For example 20 USD + 30 EURO + 40 INR  something like this  from this table </p>
  
  <p>I also have to consider the scenario if FeesCustom > 0 I have to ignore FeesNormal for the row </p>
  
  <p>Sample date and expected result is like this </p>
  
  <pre><code>  FeesNormal  FeesCustom  Currency
    10          0            USD   
    15          25           USD //in this case can ignore FeesNormal Since FeesCustom is more
    5           10           EUR //same for this row ignore FeesNormal
    10          0            EUR
  
  Expected result  35 USD 20 EUR   
  </code></pre>
  
  <p>I able to find sum using the linq</p>
  
  <pre><code> int sum_custom=(int)fee_list.Where(p =&gt; p.FeesCustom &gt; 0).Sum(p =&gt; p.FeesCustom);
   int sum_normal = (int)fee_list.Where(p =&gt; p.FeesCustom ==0).Sum(p =&gt; p.FeesNormal);
  </code></pre>