title: Sum values in datatable using linq based on conditions
body: <p>I'm having a datatable like mentioned below.</p>
  
  <pre><code>ID   Percentage  
  1        50
  1        30
  2        0
  2        100  
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <pre><code>ID   Percentage  
  1        80
  2       100
  </code></pre>
  
  <p>I tried this and it doesn't work</p>
  
  <pre><code>var n =  dt.AsEnumerable()
             .Where(r =&gt; (int)r["ID"] != "0" || (int)r["ID"] != "100")
             .Sum(r =&gt; (int)r["Percentage"]);
  </code></pre>
  
  <p>I'm new to linq and pls provide some suggestions.</p>
  
  <p>Now I need to sum the percentage for each ID and the percentage for each ID should be 0 or 100 percentage. </p>
  
  <p>If any one of the ID in table doesn't have 0 or 100 I need to alert. Pls suggest me how I can do this in linq and I think its the best way.</p>