如果我有一个DataTable userwidget
,其中包含以下列:
process_id,emp_num,widget_color
如何根据以下条件使用DataTable
过滤此LINQ
:
1- WHERE emp_num = ...
2-和process_id NOT IN (process)//process is an array of intgers
答案 0 :(得分:4)
var filtered = (from row in tbl.AsEnumerable()
where row.Field<int>("emp_num")==yourNum
&& !process.Contains(row.Field<int>("process_id"))
select row).CopyToDataTable();
答案 1 :(得分:1)
使用,where <list>.Contains( <item> )
var lstprocessid = {1, 2, 3};
var rows =
(from datatable in dtDetails.AsEnumerable()
where !lstprocessid.Contains(int.parse((datatable["process_id "]).ToString())
&& int.parse((datatable["emp_num"]).ToString())== myemp_num
select datatable).ToList<DataRow>();