获取包含特定值的数据表列的计数

时间:2017-01-30 07:27:45

标签: asp.net linq

如何获取包含特定字符串drom datatable的特定列的总数。

我跟着如下,但没有得到:

int count = _dt.AsEnumerable().Where(c => c.Field<string> 
("EffectiveShow").Equals("0")).count;

“EffectiveShow”是我的专栏名称。在该列中,我需要字符串“0”的计数。

1 个答案:

答案 0 :(得分:0)

试试这个;

int count = _dt.AsEnumerable().Where(c => c["EffectiveShow"].ToString()=="0").ToList().Count;