How to get datarow array refering to datatable 's field value with linq

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2013-10-24T09:28:21Z Indexed on 2013/10/24 9:54 UTC
Read the original article Hit count: 203

Filed under:
|

I want to use linq to get datarow array from a datatable which its string type ColumnA is not null or depending on its length >0 , so I can get the row index with Indexof() method to deal with something else.

ColumnA ColumnB ColumnC
A0       B0       C0
Null     B1       C1
A2       B2       C2
Null     B3       C3

My Linq Statment:

DataRow[] rows =  myDataTable.Select("ColumnA is not null").Where(row=>row.Field<string>("ColumnA").Length>0);

somebody who can help?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ