I have a SQL query that I want to convert into LINQ. I have pulled the data in to datatable.I am quite confused how to write the WHERE part of the query. The condition is dependent on a column in the table, If col_Con is “G” then use greater than on col_Val and 30(any value) else if col_Con is “L” then use less than condition on col_Val and 30(any value)
I am using Sqlserver 2005 for the SQL query part .
SELECT *
FROM Mytable
WHERE
CASE
WHEN col_Con= 'G' THEN
col_Val
ELSE
30
END
<=
CASE
WHEN col_Con= = 'L' THEN
30
ELSE
col_Val
END
Here is the start of my Linq
//Mytable is a DataTable
var drs = from DataRow dr in Mytable.Rows
where
...
select dr;
1 Answer