My goal is to select all rows from a datatable based on a condition where i want to test if the value falls within a range that is calculated within the table itself.
I’m having difficulties writing out the correct .select for this. Right now i have this but i am getting an error still.
The expression means:
For all of the rows in dtTemp for each row check if it contains the conditions after Where word. Get the rows which meet the conditions and save them to the data table.
I used the intial data table (dtTemp), but you can of course save it to different variable.
Mind that if such LINQ expression returns empty data table, it throws an error, so it should be handled somehow, eg. put it in try catch:
I still have to test it within the rest of the process but in seperate tests it seems to be giving me the correct array of rows! very happy with this LINQ syntax! I made sure to include a try catch and in the catch I declare an empty array.
Effectively it is allowing me to select rows based on a range of values with an upper and lower limit. Checking if “variable3containingInt” falls within the range.