This error happens over and over but only after considerable time when you have forgotten how you fixed it last time.
foreach (string colName in breakup)
{
IEnumerable res = from row in QueryCSVModel.FilteredData.Table
select row[colName]; //error on select : Cannot convert lambda expression to type 'string' because it is not a delegate type
//do something here
}
This is the solution specified here (rewriting here in case it helps you)
- Add reference to System.Data.DataSetExtensions
- Add using for System.Data and System.Linq
But this still did not work for me.
What I missed is using AsEnumerable() after DataTable, this code below works
foreach (string colName in breakup)
{
IEnumerable res = from row in QueryCSVModel.FilteredData.Table.AsEnumerable()
select row[colName];
//do something here
}
Advertisement
