I have a datatable in my vb .net solution. let's say the datatable (let's call it MyTable) has 2 columns: Emp_id
and Emp_cost
.
I want to calculate the sum of Emp_cost
for a specific Emp_id
. For example, in the example below I want to get 1500 as Emp_cost
for Emp_id = "1210"
. I wanted to use LINQ however, data stored in the Emp_cost
column are in string format. Is there anyway to use LINQ (instead of using For) for calculation the total cost? (or something like: MyTable.Compute("Sum(Emp_cost)", "Emp_id = 1210")
?
Emp_id | Emp_cost |
---|---|
1210 | 500 |
1210 | 1000 |
1220 | 100 |