DataTable linq query iteration

Posted by Ravi on Stack Overflow See other posts from Stack Overflow or by Ravi
Published on 2010-05-21T16:56:01Z Indexed on 2010/05/21 17:00 UTC
Read the original article Hit count: 231

Filed under:

Hi, I want to Enumerate Linq Query. Below i specified example.

EX:

 DataTable _slidingDataTable = new DataTable("test");

 for(int i=0; i<5;i++)
 {
  DataRow row = _slidingDataTable.NewRow();

   startPosition = DateTime.Now;
   for(int i=0; i<5;i++)
   {
      _slidingDataTable.Columns.Add("TransferTime");
       row[columnName] = startPosition ;
       _slidingDataTable.Columns.Add("TransferData");
       row[columnName] = "Test"+i;
    }

 _slidingDataTable.Rows.Add(row);
 }


 var query1 = from myRow in _slidingDataTable.AsEnumerable()
                        where myRow.Field<DateTime>("TransferTime") == startPosition
                        select myRow;

This query output should be collection of rows. How to get collection row & iterate.

© Stack Overflow or respective owner

Related posts about LINQ