Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Below is my code and it works fine but only for the first row the soldqty and Amount values are getting doubled.while other rows data is fine.I am not able to understand why only the first row data Sum(SoldQty) is getting doubled.</p> <pre><code>decimal? SoldQty, stockinhand,SellPrice,Amount,CostPrice; string ItemCode, Description,UOM,BarCode,SoldDate,Department,Category,User; var resQuery = from row in dtFilter.AsEnumerable() group row by row.Field&lt;string&gt;("Item Code") into g select dtFilter.LoadDataRow(new object[] { ItemCode=g.Key, Description=g.Select(r=&gt;r.Field&lt;string&gt;("Description")).First&lt;string&gt;(), UOM=g.Select(r=&gt;r.Field&lt;string&gt;("UOM")).First&lt;string&gt;(), SoldQty = g.Sum(r =&gt; r.Field&lt;decimal?&gt;("Sold Qty")).Value, stockinhand=g.Select(r=&gt;r.Field&lt;decimal?&gt;("Stock in Hand")).First&lt;decimal?&gt;(), SellPrice=g.Select(r=&gt;r.Field&lt;decimal?&gt;("Sell Price")).First&lt;decimal?&gt;(), Amount = g.Sum(r =&gt; r.Field&lt;decimal?&gt;("Amount")).Value, CostPrice = g.Sum(r =&gt; r.Field&lt;decimal?&gt;("Cost Price")).Value, BarCode=g.Select(r=&gt;r.Field&lt;string&gt;("Barcode")).First&lt;string&gt;(), SoldDate=g.Select(r=&gt;r.Field&lt;string&gt;("SoldDate")).Last&lt;string&gt;(), Department=g.Select(r=&gt;r.Field&lt;string&gt;("Department")).First&lt;string&gt;(), Category=g.Select(r=&gt;r.Field&lt;string&gt;("Category")).First&lt;string&gt;(), User=g.Select(r=&gt;r.Field&lt;string&gt;("User")).First&lt;string&gt;(), }, false); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload