Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32755

How to dynamically cast a Table to a List

$
0
0

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<type> where Type comes from the myObjectType Type variable.

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


Viewing all articles
Browse latest Browse all 32755

Trending Articles