C# Generics and Reflection

c++genericslinqreflection

i'm using linq. All my queries looks like var query = dc.GetTable<myType>().

I wish i could choose "myType" using a string parameter. I tried to create a Type object using reflection, but the compiler doesn't recognize Type objects as class definitions.

Any suggestions?
Thanks

Best Solution

There's a GetTable(Type) extension method which does exactly what you are looking for:

var query = dc.GetTable(Type.GetType("namespace.type, assembly"));