Forums - C# Corner

Forum guidelines

How to dynamically cast a Table to a List

Dec 12 2012 3:15 AM

I have the following piece of code:

ITable tResults = myDataContext.GetTable(myObjectType); Type myListType = typeof(List<>).MakeGenericType(myObjectType);

So, I get the table data from object type which gives me a Linq.Table object (line 1).

Now, in line 2 I dynamically create a List where Type comes from the myObjectType Type variable.

my Question: How do I convert/cast my Linq.Table to a strongly typed List List ?


Answers (1)

C# Corner Hyderabad Developer Conference

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.