I am trying to convert DataTable
into generic list List<T>
, I am getting this error :
cannot convert lambda expression to type string because it is not a delegate type
I have gone through several threads posted here on SO regarding this, most of them suggested using Entity
and Linq namespaces
, but still I am getting same error.
Here is my code:
DataTable csvData = GetDataTableFromCSVFile(csv_file_path);
List<MyClass> lst = new List<MyClass>();
lst = (from l in csvData
select new MyClass // getting red line under select
{
Address_1 = l.Address_1,
//total of 29 columns
Title = l.Title,
Town_of_Birth = l.Town_of_Birth
}).ToList();