Im trying to query a datatable using linq, ideally what I would like to do is compare a column of strings to an array of strings, returning those that match.
我试图使用linq查询数据表,理想情况下我想要做的是将一列字符串与一个字符串数组进行比较,返回匹配的字符串。
Any ideas?
Cheers in advance
提前干杯
CM
2 个解决方案
#1
3
You need to use one of the Field<T>
methods of DataRowExtensions.
您需要使用DataRowExtensions的Field
var foo = from r in dt.AsEnumerable()
where bar.Contains(r.Field<string>("barColumn"))
select r;
#2
1
myDB.Where(x=> array.Contains(x));
#1
3
You need to use one of the Field<T>
methods of DataRowExtensions.
您需要使用DataRowExtensions的Field
var foo = from r in dt.AsEnumerable()
where bar.Contains(r.Field<string>("barColumn"))
select r;
#2
1
myDB.Where(x=> array.Contains(x));