Reputation: 357
I'm selecting some data from table A
with a column value
and type which have relationship with table B
where there is a column coef
that contains (-1,0,1)
When retrieving from A
I want to multiply the value
with coef
.
Upvotes: 0
Views: 620
Reputation: 944
You could use a LINQ expression to do it in one line:
dt.Rows.ForEach(x => x["value"] = (double)x["value"] * (double)x["coef"]);
or you could just add another column to the DataTable:
dt.Columns.Add("Result", typeof(decimal));
dt["result"] = "value * coef";
Upvotes: -1
Reputation: 56429
Something like this?
var result = from a in tableA
join b in tableB on a.Key = b.ForeignKey
select new
{
Value = a.value * b.coef
};
Upvotes: 5