I’m working on a system in which the DB call returns a Strongly Typed list. I need to intercept the list, make changes to the data and then send it on. This is time sensitive, high volume and through put app; so I need a very efficent way to do this conversion. Because of the nature of the data manipulations I’m converting the list to a datatable. The conversion to a DT is no problem as is the manipulation; the conversion back to a Strongly Typed List is the problem. I must convert it back as the down stream code expects a List. I’ve looked and most pages talk about converting a List to DataTable, a couple do conversion of a Datatable to GENERIC List not Typed List.
I have tried AsEnumerable() and ToList(), the problem is assigning it back to the typed list.
Logic:
List<< TypedlistDef>> Lst = new List<< TypedlistDef>>();
DataTable dt = new DataTable();
dt = Helper.ListToDataTable(Lst)
manipulate dt
Lst = List<< TypedlistDef>>dt.???????? <---- Problem
I’m working in VS2010 Framework 3.5.
Thank You in advance for any and all help.
You can use Linq to DataSets if you like
Here’s a full example
using foreach over the DataTable.Rows and adding them to the list will also work