i need to evaluate generic type at runtime using Type.GetType()
Type t = Type.GetType("className");
Table<t> table = dataContext.GetTable<t>();
any ideas please ??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, normally you need to get the generic method (e.g. with
Type.GetMethod), then callMethodInfo.MakeGenericMethod, then invoke it.However, is there any reason you don’t just want to call
DataContext.GetTable(Type)?You won’t be able to use the table generically anyway… so is
ITable(the return type ofGetTable(type)) good enough for you?