Reputation: 5179
I've scenario where the datatable may contain large number of rows. As a result i am not able to iterate and update the datatable using a loop.
I've tried the following code,
from row in table.AsEnumerable()
where table.Columns.Any(col => !row.IsNull(col))
select row;
But i can't find definition for Any(). Is there any namespace i should use to get Any()?
Any body please tell me how to correct this or suggest any alternate solutions..
Upvotes: 4
Views: 2673
Reputation: 4683
use system.linq
namespace if framework version is greater than 2
Upvotes: -1
Reputation: 19070
Apart from having to use the System.Linq
namespace you also need to make it aware of the element types. DataTable.Columns
is not a generic collection (it implements only IEnumerable
not IEnumerable<T>
) and the compiler cannot infer the type. You need to do something like this:
from row in table.AsEnumerable()
where table.Columns.Cast<DataColumn>.Any(col => !row.IsNull(col))
select row;
Upvotes: 7
Reputation: 7126
The Any()
method is in the System.Linq
namespace. The Method lives in the Queryable
class
Upvotes: -1