我有一个包含两列的数据表,

Column 1 = "EmpID"
Column 2 = "EmpName"

我想查询数据表,针对列EmpIDEmpname

例如,我想获取值
(EmpName != 'abc' or EmpName != 'xyz') and (EmpID = 5)

最佳答案

像这样

var res = from row in myDTable.AsEnumerable()
where row.Field<int>("EmpID") == 5 &&
(row.Field<string>("EmpName") != "abc" ||
row.Field<string>("EmpName") != "xyz")
select row;

也可以看看
LINQ query on a DataTable

10-06 07:46