使用 where 条件查询数据表 [英] Querying Datatable with where condition
本文介绍了使用 where 条件查询数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含两列的数据表,
I have a datatable with two columns,
Column 1 = "EmpID"
Column 2 = "EmpName"
我想查询数据表,针对列 EmpID
和员工姓名
.
I want to query the datatable, against the column EmpID
and
Empname
.
例如,我想获取其中的值
For example, I want to get the values where
(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;
这篇关于使用 where 条件查询数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文