Compare input double with datatable string column values within a range using between query(SQL server query to Linq on datatable c# )
DataTable has below columns and all are strings.
Value From | Value To | %
1.00 1.50 10.6%
1.51 2.0 20.4%
2.01 2.50 25.5%
User given input value is double. I have to get the % column value from datatble where user given input matches in between the range 'Value From' and 'Value To'
Ex: If input is 1.81 then I should get 20.4% as a query result.
If user gives 2.05 then I should get 25.5% as a query result.
If user gives 1.35 then I should get 10.6% as a query result.
I'm able to get the same result with sql query from sql server stored procedure:
select % from [TestDatabase_GPA].[dbo].[AcadamicGPA] where @Acadamic_GPA between Value From and Value To
How can I convert SQL query to get same result from DataTable using Linq or select. Here the problem is I have to convert the datatable column datatype string to double and then perform between operation. I tried this Compare string values with double in DataTable.Select() but I didn't get required result. I'm new to Linq please share with me any sample code or any ideas would be appreciated.