Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

querying and get distinct from a datatable

$
0
0

Hi list,

I have a datatable which I need to get some details from. The dt has an integer type column "mycolumn", which has data of -1 or other positive number. Now all I want to do is to take only those rows with positive figures, then count number of distinct one. For example if I got: -1, 2, -1, 3, 2, 3, -1, -1, 2, 3, I need to get 2, which means there are only two numbers which are not -1.

String Q= “where mycolumn<>-1“

Int n= elt.select(Q).count(r => r.field<int>(“eltrow“));

first I got this error: "Cannot implicitly convert type int to bool" , then do now know how to finish the code even if I fix the error.

would you please help me on this?

thanks

Arvin



Viewing all articles
Browse latest Browse all 8156

Trending Articles