none
Can't Convert IEnumerable<DataRow> to DataTable RRS feed

  • Question

  • Expression< Func<string, IEnumerable<DataRow>>> GetRow = (s) =>  Table.select( @"columnName='"+s+"'");

    GetRow.CopyToDataTable( table, LoadOptions.OverwriteChanges);

    I got the error .. .Help me to rectify the error.. . 



    • Edited by Ramkumar.B Saturday, February 23, 2013 3:05 PM
    Saturday, February 23, 2013 1:09 PM

Answers

  • I don't think you need 'Expression' there. You can directly do it as,

    Func<string, IEnumerable<DataRow>> GetRow = (s) =>  Table.select( @"columnName='"+s+"'");
    GetRow("<ColumnName>").CopyToDataTable( table, LoadOptions.OverwriteChanges);
    

    I hope this helps.

    Please mark this post as answer if it solved your problem. Happy Programming!

    Monday, February 25, 2013 12:34 PM

All replies

  • Those lines should get you an error stating that Expression doesn't contain a definition for CopyToDataTable.

    Could you copy the actual lines?

    Monday, February 25, 2013 10:30 AM
  • I don't think you need 'Expression' there. You can directly do it as,

    Func<string, IEnumerable<DataRow>> GetRow = (s) =>  Table.select( @"columnName='"+s+"'");
    GetRow("<ColumnName>").CopyToDataTable( table, LoadOptions.OverwriteChanges);
    

    I hope this helps.

    Please mark this post as answer if it solved your problem. Happy Programming!

    Monday, February 25, 2013 12:34 PM