I am currently trying to find the value of a column by comparing the value of another column with a reference number.
Let me explain:
I have a DataTable with 2 columns.
ID DATA
1 120
2 200
3 -60
4 478
I want to find the ID of the DATA closest from 0.
In this case the correct value will be -60 and the ID 3
I actually do that
int closestId = dtQueryLambda.AsEnumerable().Where(x => x.Field<double> ("DATA") > 0 ||
x.Field<double>("DATA") < 0)
.Select(x => x.Field<Int32>("ID"))
.First();
Can someone help me?