Check for datarows returned

I have these that check datarows that match the expression:

DataRow[] foundRows = this.callsTable.Select(searchExpression);

How to check if it returns some datarows, so basically, if it returns none, does not do what in the if function?

I tried:

if (foundRows != null) { }
+4
source share
4 answers

You can use the Lengtharray property to check for any rows

if (foundRows.Length == 0) 
+9
source

You can use the Count method to check:

if (foundRows.Count() == 0)
+1
source

LINQ

var areThereAny = foundRows.Any();

var count = foundRows.Count();

, - , , :

var anyThatMatch = this.callsTable.Any(selectCondition);
0

   if (foundRows.Length > 0) 
   {
        //Your code here
   }

Count()

   if (foundRows.Count() > 0)
   {
     //Your code here
   }
0

All Articles